[英]Run shell_exec Function in PHP Not Work
run "mumudvb -l" command in the linux terminal has correct output. 在Linux终端上运行“ mumudvb -l”命令具有正确的输出。 but in php the output is nothing.like this: 但在php中,输出是没有什么。
$output = exec('mumudvb -l');
$output = shell_exec('mumudvb -l');
$output = "" //the output
why this happen? 为什么会这样?
You cannot use this function because php.ini know it's disabled functions in config file 您无法使用此功能,因为php.ini知道它已在配置文件中被禁用
+Solution: Open your php.ini, find disable_functions
and remove your function then restart web server. +解决方案:打开php.ini,找到disable_functions
并删除功能,然后重新启动Web服务器。 BTW, becareful because security problem you may have. 顺便说一句,请小心,因为您可能遇到安全问题。 You should improve your server security 您应该提高服务器安全性
On Linux machines, setting that certain value in php.ini does not always work. 在Linux机器上,在php.ini中设置某些值并不总是有效。
What I did was add the following sudoers group: %admin ALL=NOPASSWD: ALL
then make the www-data user run as admin usermod -G admin www-data
next, all the commands that you use with shell_exec, prefix them with sudo. 我所做的是添加以下sudoers组: %admin ALL=NOPASSWD: ALL
然后使www-data用户以admin usermod -G admin www-data
身份运行,接下来,将要与shell_exec一起使用的所有命令都以sudo前缀。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.