Page 1 of 1

PHP Access Denied

Posted: Thu Sep 24, 2009 5:39 pm
by cclough
For some reason I cannot get a PHP script to mkdir when executed from a web browser.

Using Fedora 10, Apache2, and PHP 5.2something

I have created a directory called:
/mydir

Here are the permissions w/ ls -l
drwxrwxrwx 2 cclough www 4096 2009-09-24 10:51 mydir

here are the users of the group www:
[root@webserver0 /]# lid -g www
mysql(uid=27)
apache(uid=48)
cclough(uid=500)
root(uid=0)
nobody(uid=99)

here is the command in my script:
mkdir("/mydir/exports") or die("FAIL");

and the error:
Warning: mkdir() [function.mkdir]: Permission denied in /var/www/includes/expshell.php on line 17
FAIL

For some reason PHP cannot create directories when run from a browser. However, if I run the script from the command line, presto! It works fine.... Even stranger, I can run the script from the browser IF I change the directory to /tmp, and ownership on the directory is root:root. I am also having a simular situation with mysql SELECT INTO OUTFILE. So I'm feeling that this isn't a permission issue and some other security feature is doing this?

SELinux is disabled also.

THanks!!!! This is driving me crazy

Re: PHP Access Denied

Posted: Thu Sep 24, 2009 7:19 pm
by Christopher
The problem is that the webserver (and PHP) run as a different user than you (on the command line). So you need to change the permissions on the directory or change the owner to be the same as the webserver.

Re: PHP Access Denied

Posted: Thu Sep 24, 2009 7:26 pm
by requinix
You sure you have the path to "mydir" correct? No /mydir unless you actually mean it's located at the root?

(/tmp is special, permissions are a bit different with it)