Mcdir (): permission denied

I have 777 for all files on my server. PHP 5.4 (no safe_mode)

The site runs on other servers. This is the structure of Yii

mkdir(): Permission denied /var/www/html/project/framework/web/CAssetManager.php(225) 213 return $this->_published[$path]; 214 elseif(($src=realpath($path))!==false) 215 { 216 $dir=$this->generatePath($src,$hashByName); 217 $dstDir=$this->getBasePath().DIRECTORY_SEPARATOR.$dir; 218 if(is_file($src)) 219 { 220 $fileName=basename($src); 221 $dstFile=$dstDir.DIRECTORY_SEPARATOR.$fileName; 222 223 if(!is_dir($dstDir)) 224 { 225 mkdir($dstDir,$this->newDirMode,true); 226 chmod($dstDir,$this->newDirMode); 227 } 

Here ls -l after chown, not help

 drwsrwsrwx. 2 apache apache 4096  3 16:44 assets drwxrwxrwx. 5 apache apache 4096  10 14:52 bootstrap drwxrwxrwx. 19 apache apache 4096  3 16:04 framework -rwxrwxrwx. 1 apache apache 326  3 16:42 index.php drwxrwxrwx. 10 apache apache 4096  3 16:04 protected drwxrwxrwx. 3 apache apache 4096  20 13:28 soap drwxrwxrwx. 3 apache apache 4096  3 16:04 themes 
+6
source share
4 answers

Check SELinux and turn it off. Now it works!

+1
source

Make sure that:

  • The web directory belongs to the apache user. ("ls -al" will tell you)
  • the parent directory that you want to create also belongs to this user.
  • the parent directory is not a mount in which you do not have write permissions.
  • the path you want to create is correct (var_dump ($ dstDir) will tell you)
  • $ this-> newDirMode contains the correct permission value. (If you work in windows, this will be ignored)

If there are no problems, and I still won’t work:

  • make yourself an apache user and try creating it manually ("sudo -u apache" if your username is apache)
  • try omitting the third parameter "true" in "mkdir ($ dstDir, $ this-> newDirMode, true); and create all the directories one by one
  • check logs ("/ var / log / apache" is your friend)

Hope this helps.

+4
source

SELinux can be a problem. Try disabling it manually:

 setenforce 0 
+3
source

SELinux was the culprit in my setup. Thank you for reminding!

+1
source

Source: https://habr.com/ru/post/948631/


All Articles