在PHP中运行着的shell脚本
当我试图与运行shell脚本 EXEC
和 shell_exe
什么也没有发生!
当我和那些命令来运行 LS
或 WHOAMI
一切工作的。
When I am trying to run shell script with exec
and shell_exe
nothing happens!
When I run with those command ls
or whoami
all work's.
什么会是什么?
你呼应的输出?
echo exec('ls');
您已经启用safe_mode设置?
Do you have safe_mode enabled?
phpinfo();
当是:(从手动)
请注意:当启用安全模式时,你只能执行中的文件
safe_mode_exec_dir之。出于实际的原因,它目前不允许
有..组件中的可执行文件路径。
Note: When safe mode is enabled, you can only execute files within the safe_mode_exec_dir. For practical reasons, it is currently not allowed to have .. components in the path to the executable.
尝试调用exec以
exec('...pathtoyourbashscript...', $out, $return);
然后
echo $return;
如果它显示 127
可能汇入作业的路径是错误的。
If it shows 127
it´s likely that the path is wrong.
另外,还要检查权限。用户没有人可能是apache用户,需要的权限访问和执行脚本。
Also check the permissions. User 'nobody' is probably the apache user, which needs the rights to access and execute the script.
您可以通过运行更改权限
You can change the permissions by running
行chmod 755 pathtouyourscript
这意味着像'如果其他人读取或运行此文件,我不介意,但只有我应该能够修改。
This means something like 'I don't mind if other people read or run this file, but only I should be able to modify it'.