PHP Access Denied

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cclough
Forum Newbie
Posts: 1
Joined: Thu Sep 24, 2009 5:37 pm

PHP Access Denied

Post 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
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: PHP Access Denied

Post 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.
(#10850)
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: PHP Access Denied

Post 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)
Post Reply