Page 1 of 1

faild to create path with chmod 777

Posted: Sat Jun 05, 2010 5:08 pm
by hueman
i need to create nested directories with chmod 777, i tried following code but every directory created with chmod 755 in CentOS, in windows this code create directories with chmod 777, whats the problem?

Code: Select all

$dir = "a";
$folders = array('b','c','d');
foreach($folders as $f)
{
   $dir = $dir."/".$f;
   if(!is_dir($dir))
   {
      if(mkdir($dir))
         echo $f.' was created<br>';
      else
         echo 'failed to create '.$f.'<br>';
      if(chmod($dir, 0777))
         echo $f.' chmod converted to 777<br>';
      else
         echo 'failed to convert '.$f.' chmod to 777<br>';
   }
}
i tried to create my path (eg: 'a/b/c/d') with mkdir('a/b/c/d',0777,true) but this code create directories with chmod 755 too, i didnt success to convert chmod to 777 by applying chmod() to every directories, what can i do to create a path like 'a/b/c/d' with chmod 777 for every directories in CentOS?

Re: faild to create path with chmod 777

Posted: Sat Jun 05, 2010 5:29 pm
by Eran
PHP probably does not run in the same group as the process that created the directories (most likely, it is running as 'Unknown' or 'nobody'). You should set PHP to run under the user/group that owns the directories (most likely, apache) in order to apply chmod.

Re: faild to create path with chmod 777

Posted: Sun Jun 06, 2010 4:26 am
by hueman
pytrin wrote:PHP probably does not run in the same group as the process that created the directories (most likely, it is running as 'Unknown' or 'nobody'). You should set PHP to run under the user/group that owns the directories (most likely, apache) in order to apply chmod.
thank you for responding me
how can i apply this setting?

Re: faild to create path with chmod 777

Posted: Sun Jun 06, 2010 4:42 am
by Eran