Can't use apache/www-data to run commands, which user should be used?

Re: Can't use apache/www-data to run commands, which user should be used?

by Ken Task -
Number of replies: 0
Picture of Particularly helpful Moodlers

When the bash shell environment doesn't find php-cli it might be due to environmental paths of the user.

As the user in a bash shell, type 'env' and look for the $PATH.

Once one finds the path the the php-cli (which might show as 'php'), one can change the bash shell environment with an alias for php that points to the php-cli

nano .bashrc

Just below the #User specfic aliases and functions comment

alias php=/path/to/bin/php

Save the .bashrc file

Log out.  Log back in.  Or reload the environment ... source .bashrc

which php should show your alias

and then the scripts in moodlecode/admin/cli/ can be run without the full path to the php-cli.

from within moodlecode/admin/cli/

php nameofscript.php

Help on the scripts will still suggest /usr/bin/php.

Note: I've had to do this with 2 different providers ... both using cPanel and ea-php#.# for multiple versions of PHP.   If one updates the ea-php to a higher version of PHP then the alias path might need to change.

'spirit of sharing', Ken