Page 1 of 1

Question about mkdir() on apache

Posted: Wed May 21, 2008 6:13 pm
by dmsweets
Hi,

I'm having problems implementing a simple upload script which creates a directory and uploads images to that folder. mkdir() works but the uid and gid are owned by apache. As a result the newly created folder cannot be accessed. I have scowered the internet for documentation on this subject but to no avail.

My code is more complicated but for the purpose of testing I have created a very simple page with code as follows:

Code: Select all

 
 
<?php 
 
mkdir("/var/www/vhosts/mirandamoser.com/httpdocs/author/test", 0777);
 
?>
 
 
Has anyone else encountered this problem and if so is there a solution?

Thanks in advance

Re: Question about mkdir() on apache

Posted: Wed May 21, 2008 6:15 pm
by Benjamin
Look into the chmod function.

Re: Question about mkdir() on apache

Posted: Wed May 21, 2008 6:29 pm
by dmsweets
Like I said in the above post the the uid and gid are apache. As such, nothing can be used to change the permissions including php, plesk and ftp. The only option I have with the newly created folder is to delete it.

Re: Question about mkdir() on apache

Posted: Wed May 21, 2008 7:38 pm
by dmsweets
Even the server techs don't know about this issue because they have told me to change the script but how can I make this any simpler?

Re: Question about mkdir() on apache

Posted: Thu May 22, 2008 4:15 am
by VladSun
dmsweets wrote:As a result the newly created folder cannot be accessed.
What do you mean by that - which user can and which can not access it? What do you mean by "cannot be accessed" - read, write, list ...?

Re: Question about mkdir() on apache

Posted: Thu May 22, 2008 12:05 pm
by pickle
The 'apache' user created the directory, so it will definitely have the access rights necessary to allow you to run chmod() - the PHP function chmod(), not the shell executable. Change it so the world can access it & you should be good to go.

Re: Question about mkdir() on apache

Posted: Thu May 22, 2008 3:37 pm
by Benjamin
Yes, as pickle and I have already stated:
astions wrote:Look into the chmod function.