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
PHP Access Denied
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: PHP Access Denied
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.
(#10850)
Re: PHP Access Denied
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)
(/tmp is special, permissions are a bit different with it)