I need my PATH environment variable to include /usr/local/bin when seen from PHP, so that I can execute binaries that are in /usr/local/bin with exec() in PHP code without writing their full path, e.g. exec("ffmpeg");
If from php I run echo getenv("PATH") it outputs: /sbin:/usr/sbin:/bin:/usr/bin
However if I log into the server as root via ssh and I write in the terminal echo $PATH I get: //sbin://bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
So the /usr/local/bin is already included when I log into the command line, but not when PHP is run.
So how do I add directories to the path environment variable in such a way that they are recognized also by PHP?
I tried to add SetEnv PATH $PATH:/usr/local/bin to /var/www/vhosts/mydomain.net/conf/vhost.conf (which contains other directives which do have effect), but it doesn't change a thing. I also tried by adding that to a .htaccess file (dunnow if it made sense) but it didn't work either.
I already searched the forum and found a lot of similar or identical questions but no answer, or at least none that works.
In your apache startup script, try to export your custom path.
IIRC, Apache defaults to common envvars when started. So, even changing its value in user's env won't do the trick.
Well, depending on your needs you can either set it in the script (Documenation Link)
or you can set it in the php.ini file itself (Documentation Link)
edit the php.ini the clause include_path indicate in which path php take the script.