且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在PHP中运行着的shell脚本

更新时间:2022-11-15 21:45:51

你呼应的输出?

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'.