PHP Error on OpenBSD: "env: php: No such file or directory"

nabbisen - Jul 25 '19 - - Dev Community

* The cover image is originally by 13smok and edited with great appreciation.


In OpenBSD, a symbolic link named php isn't created when installing PHP:

# pkg_add php
Enter fullscreen mode Exit fullscreen mode

The result is:

$ ls -1 /usr/local/bin/php*
/usr/local/bin/php-7.3
/usr/local/bin/php-config-7.3
/usr/local/bin/phpize-7.3
Enter fullscreen mode Exit fullscreen mode

It's OK because php-X.X works well in most cases:

$ php-7.3 /usr/local/libexec/composer.phar require drush/drush
Enter fullscreen mode Exit fullscreen mode

$PATH missing php, however, sometimes occurs an unexpected error with some PHP modules such as Drush, a command line shell for Drupal CMS:

$ drush updatedb
env: php: No such file or directory
Enter fullscreen mode Exit fullscreen mode

It tried to run php which was missed!

In such a case, creating the symlink is helpful:

# ln -s /usr/local/bin/php-7.3 /usr/local/bin/php
Enter fullscreen mode Exit fullscreen mode

Then the error will be resolved:

$ drush updatedb
 [success] No pending updates.
Enter fullscreen mode Exit fullscreen mode

Remove the additional symlink afterward as needed:

# rm /usr/local/bin/php
Enter fullscreen mode Exit fullscreen mode

Thank you for your reading.
Happy computing :)

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .