Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mkdir(): Permission denied

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

Site works on other servers. It's Yii framework

 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
like image 577
awMinor Avatar asked Jul 03 '13 14:07

awMinor


People also ask

How do I fix mkdir permission denied?

[ErrorException] mkdir(): Permission denied. That means you do not have write permission on your project folder. Create a new folder, say 'myproject and run sudo chmod 777 myproject . Then move to 'myproject' folder and create project.

Why can't I create a directory permission denied?

If you receive an error telling you that you do not have permissions to create a directory or to write a file to a directory, this is likely an indication that your script is attempting to write to a directory that you do not own.

How do you fix mkdir Cannot create directory?

Resolving The Problem Simply log in as super user “su” and use “chmod 777” to set the directory permissions of where you wish the rational directory to be created. Once done, you can re-enter the original directory again and the install will continue using the same directory.


2 Answers

Make sure that:

  • the web directory is owned by the apache user. ("ls -al" will tell you)
  • the parent directory in which you want to create is also owned by this user.
  • the parent directory isn't a mount in which you don't have write permissions
  • the path you want to create is correct (var_dump($dstDir) will tell you)
  • $this->newDirMode is contains a correct permission value. (If you are running on windows this will be ignored)

If there is no problem and it still doesn't work I would do:

  • make yourself the apache user and try to create it manually ("sudo -u apache" if your username is apache)
  • try to omit the third parameter 'true' in "mkdir($dstDir,$this->newDirMode,true);" and create all directories one after another
  • inspect the logs ("/var/log/apache" is your friend)

Hope this helps.

like image 191
cb0 Avatar answered Sep 20 '22 05:09

cb0


SELinux may be the problem. Try turning it off manually:

setenforce 0
like image 40
Keith Wagner Avatar answered Sep 23 '22 05:09

Keith Wagner