RE: [PHP-GENERAL] mkdir function and permissions HELP!

From: Date: Thu, 15 Jun 2000 19:54:13 +0000
Subject: RE: [PHP-GENERAL] mkdir function and permissions HELP!
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-1997@lists.php.net to get a copy of this message
Ok, here's the skinny... Like in IIS/NT, file permission don't allow an anonymous user to write to any directory on in the filesystem for obvious security reasons. User 'nobody' is the Linux equiv. of user 'anonymous' on NT. With IIS, you'd have to allow the group "World" access to write to a directory for the webserver to write to it. This holds for PHP/Apache. If you don't have access to write to a directory, you can't create anything in it, including directories. There are two solutions to this. First, you can open up the permissions on the parent directory to allow world write access. This isn't a good idea unless nothing sensitive is in there. This is a common practice for the cgi-bin. To do this, you need to telnet or login to the server and use the following command: chmod 777 /path/to/dir The second option is to use something to authenticate the owner of the parent directory like LDAP. This would most likely need to be installed on the server and have PHP/Apache recompiled --with-ldap. Then you could create the directory as the owner of parent directory. I'm sorry if my IIS/NT lingo isn't the best. It's been awhile. (And will be even longer) Jason > -----Original Message----- > From: Chris Hughes [mailto:Chris@ecomshare.com] > Sent: Thursday, June 15, 2000 1:30 PM > To: jasonc@webpipe.net > Subject: RE: [PHP-GENERAL] mkdir function and permissions HELP! > > > no no, I"m totally new to apache and linux...normally an IIS man (glad I > switched) The simpler you make it the better. I am a little confused. > isn't > mkdir("/tmp/mydir",0755); > esentially what I am doing? > > =)...should I wait for our apache guy to get back from Vegas to switch > something on the server =) > > -----Original Message----- > From: Jason [mailto:jasonc@webpipe.net] > Sent: Thursday, June 15, 2000 1:16 PM > To: Chris Hughes; php-general@lists.php.net > Subject: RE: [PHP-GENERAL] mkdir function and permissions HELP! > > > Chris > > 0755 is just your standard octal permission set in Unix/Linux. > If you do an > "ls -l" on that directory, you'll notice the permission list like this: > > drwxr-xr-x (read=4 write=2 execute=1) The order goes (Owner/Group/World) > > So 755 would be > Owner(read,write,execute[4+2+1]),Group(read,execute[4+1]),World(re > ad,execute > [4+1]) or 755. The leading 0 is the sticky bit which you shouldn't worry > about right now. I'm guessing your webserver is running as user "nobody" > which generally goes under the World permissions and PHP doesn't have > permissions to create a directory there. Try this: > > mkdir("/tmp/mydir",0755); > > That will probably work because the permissions are set to world writable. > (0777) I'm sorry if I'm over-simplifying everything and you already know > all of this. > > Jason > > <snip> > > darn, I still get > > Warning: MkDir failed (Permission denied) in > > /home/epcra/html/admin/test.php3 on line 15 > > > > Is this a setting that needs to be switched on the server? > > > > > > FYI...here is the code I'm using > > > > if (mkdir("/home/epcra/html/testdir",0755)) > > { > > echo "Directory Creeated"; > > } > > else > > { > > echo "Not Created"; > </snip> > > > -----Original Message----- > > From: Chris Hughes [mailto:chris@ecomshare.com] > > Sent: Thursday, June 15, 2000 12:34 PM > > To: php-general@lists.php.net > > Subject: Re: [PHP-GENERAL] mkdir function and permissions HELP! > > > > > > is this mode a setting in apache? the 0755 did seem to work. > Forgive me, > > its my first time working with apache > > "Jason" <jasonc@webpipe.net> wrote in message > > news:NEBBIJABFKPPGJFBNIGLIEDACIAA.jasonc@webpipe.net... > > > I'm not sure if this question has already been answered. If so please > > > disregard. The default for Unix/Linux for directories is 0755. > > I believe > > > if you leave the mode out of the function it will default to > > this as well. > > > You will want to remember that php runs as the apache user if > > it's run as > > a > > > module. So in most cases this is user 'nobody'. The user must have > > > permissions to create a directory or it won't work. > > > > > > Jason > > > > > > > -----Original Message----- > > > > From: Chris Hughes [mailto:chris@ecomshare.com] > > > > Sent: Thursday, June 15, 2000 11:20 AM > > > > To: php-general@lists.php.net > > > > Subject: [PHP-GENERAL] mkdir function and permissions HELP! > > > > > > > > > > > > Hi, > > > > I'm trying to use the mkdir function in php to create a simple > > > > directory > > > > on the server (we are running linux/apache) and I keep having a > > > > permissions > > > > problem. I don't understand what I should put in as the > > "mode" for the > > > > second argument for the mkdir function. Please someone > help me...this > > is > > > > driving me insane. > > > > Thanks in Advance > > > > Chris > > > > > > > > > > > > > > > > > > > > -- > > > > PHP General Mailing List (http://www.php.net/) > > > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > > > For additional commands, e-mail: php-general-help@lists.php.net > > > > To contact the list administrators, e-mail: > > php-list-admin@lists.php.net > > > > > > > > > > > > > > > > > _______________________________________________________ > > > Site Design, Hosting, and E-Commerce at www.webpipe.net > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > > For additional commands, e-mail: php-general-help@lists.php.net > > > To contact the list administrators, e-mail: > php-list-admin@lists.php.net > > > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > For additional commands, e-mail: php-general-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > > > > _______________________________________________________ > Site Design, Hosting, and E-Commerce at www.webpipe.net > > _______________________________________________________ Site Design, Hosting, and E-Commerce at www.webpipe.net

« previous php.general (#1997) next »