简体   繁体   中英

PHP shell_exec cannot find environment variable

I have added this line PATH DEFAULT=${PATH}:~/bin/ to the ~/.pam_environment This allows me to call ffmpeg from command line without path which is obviously in ~/bin/ dir so everything works fine as long as im ussing command line.

But if try to run the exact same command from php all i get is sh: ffmpeg: not found And the code is

shell_exec("ffmpeg 2>&1");

So from my very little experiance with linux (in this case Ubuntu to be specific) i guess apache has no access to pam_environment or ~/bin

What can i do to make this work?

look at the output of phpinfo() , it has a section with all environment variables it sees. then look at your webserver configuration, maybe it's sanitizing the environment, or maybe the init script which starts your webserver does it.

and is the account the webserver is running under using PAM at all?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM