HelloWorld
HelloWorld

Reputation: 3749

proc_open() fails with 'Permission denied'

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') is false.

What could be wrong?

I'm using CentOS, Apache and PHP 5.3.3.

Upvotes: 3

Views: 4315

Answers (1)

John Murphy
John Murphy

Reputation: 397

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. 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 into the /var/www directory and reset the file contexts:

restorecon -RF /var/www/

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(/.*)?"

which will basically say that your program belongs to httpd.

Upvotes: 4

Related Questions