proc_open()失败,“权限被拒绝” [英] proc_open() fails with 'Permission denied'

查看:1120
本文介绍了proc_open()失败,“权限被拒绝”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用 proc_open()执行程序并打印结果。不过,我不断收到权限被拒绝。已为脚本和可执行文件,但无济于事设置chmod命令0777。

I'm trying to use proc_open() to execute a program and print the results. However, I keep getting 'Permission denied'. Have set chmod to 0777 for the script and executable, but to no avail.

ini_get('的safe_mode')是假的。

有什么地方出错了?

我使用CentOS的,Apache和PHP 5.3.3。

I'm using CentOS, Apache and PHP 5.3.3.

推荐答案

我有这个问题有相同的设置,这个问题原来是SELinux的(这是在默认情况下)preventing的httpd从执行我的外部程式。你可以把它在许可的模式,通过

I had this problem with an identical setup, and the problem turned out to be SELinux (which is on by default) preventing httpd from executing my external programs. You can put it in permissive mode via,

setenforce permissive

如果你看到同样的问题,当时的我,一切都应该现在的工作。这将持续直到您重新启动。

If you're seeing the same problem I was, everything should now work. This will last until you reboot.

要确认修改,去到/ etc / SELinux的/ config中,并更改:

To make the change permanent, go to /etc/selinux/config, and change:

SELINUX=enforcing

SELINUX=permissive

编辑:

好吧,我找到了一种方法可以做到这一点并不需要关闭SELinux的。这个问题,我的理解是,httpd的拥有自己的域名,并不能触摸它之外的东西。所以,做最简单的事情就是你的脚本/程序移动到在/ var / www目录树。

OK, I found a way to do this that doesn't require turning off SELinux. The problem, as I understand it, is that httpd has its own domain and can't touch things outside it. So, the simplest thing to do is to move your scripts/programs into the /var/www directory tree.

如果这是不可能的,而是可以改变你的程序的范围内就地:

If that's not possible, you can instead change the context of your program in-place:

semanage fcontext -a -t httpd_sys_content_t "/path/to/program(/.*)?"

这基本上会说,你的程序属于的httpd。

which will basically say that your program belongs to httpd.

这篇关于proc_open()失败,“权限被拒绝”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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