[英]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. 我已经将这行
PATH DEFAULT=${PATH}:~/bin/
到~/.pam_environment
这使我可以从命令行调用ffmpeg
而没有路径,而该路径显然在~/bin/
dir中,因此只要即时通讯使用命令行。
But if try to run the exact same command from php all i get is sh: ffmpeg: not found
And the code is 但是,如果尝试从php运行完全相同的命令,我得到的都是
sh: ffmpeg: not found
,代码是
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
因此,从我很少使用linux的经验(本例中为Ubuntu)开始,我猜想apache无法访问
pam_environment
或~/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. 查看
phpinfo()
的输出,它有一个包含所有环境变量的部分。 then look at your webserver configuration, maybe it's sanitizing the environment, or maybe the init script which starts your webserver does it. 然后查看您的Web服务器配置,可能是在清理环境,或者可能是启动Web服务器的初始化脚本完成了。
and is the account the webserver is running under using PAM at all? 并且Web服务器在使用PAM的情况下是否正在运行该帐户?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.