PHP执行shell命令的权限被拒绝 [英] PHP execute shell command permission denied

查看:1193
本文介绍了PHP执行shell命令的权限被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过安装自制软件的应用程序(bagit),我试图从我的本地Apache服务器(安装在OSX)执行shell命令。

I installed an application (bagit) via homebrew and am trying to execute a shell command from my local Apache server (installed on OSX).

我的PHP是这样的:

$cmd =  'bag create '.$targetFolder.' '.$sourceFolder.' --baginfotxt '.$bagInfoFile ." 2>&1";
$output = shell_exec($cmd);

不过,我收到以下错误消息:

However, I am getting the following error message:

/斌/ bash中:在/ usr / local / bin目录/袋:权限被拒绝

如何给Apache访问到位于`在/ usr / local / bin目录?

How can I give Apache access to the bash command located in `/usr/local/bin?

推荐答案

您安装Apache将需要运行相同的用户/组作为其试图执行的文件。

Your apache install will need to be running as the same user/group as the files its trying to execute.

您可以更改您要执行的相同的Apache / PHP的当前用户/组应用程序的文件权限(或777等)

You can either change the file permissions of the application you are trying to execute to the same as apache/php current user/group (or 777 etc..)

也可以更改阿帕奇/ PHP作为一个更priviliaged用户/组运行。

or you can change apache/php to run as a more priviliaged user/group.


  • 或者

  • Alternatively

您可以改变您的应用程序SSH的方法到可执行环境,并通过SSH执行应用程序。

You could change the method of your application to SSH into your executable environment and execute the application over SSH.

这篇关于PHP执行shell命令的权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆