Mkdir Permission denied

Hi,
I haven’t got any experience.

Tried to install grav. Worked through the permissions troubleshooting section. Still no joy.

I run grav on apache provided with macos sierra. I used the following guide to set up Apache and PHP: https://coolestguidesontheplanet.com/get-apache-mysql-php-and-phpmyadmin-working-on-macos-sierra/

I keep getting the following error

Fatal error: Uncaught exception 'RuntimeException' with message 'Creating directory '/Users/akurczych/Sites/grav/cache//compiled/files' failed on error mkdir(): Permission denied' in /Users/akurczych/Sites/grav/vendor/rockettheme/toolbox/File/src/File.php:424 Stack trace: #0 /Users/akurczych/Sites/grav/vendor/rockettheme/toolbox/File/src/File.php(195): RocketTheme\Toolbox\File\File->mkdir('/Users/akurczyc...') #1 /Users/akurczych/Sites/grav/vendor/rockettheme/toolbox/File/src/File.php(320): RocketTheme\Toolbox\File\File->lock() #2 /Users/akurczych/Sites/grav/vendor/rockettheme/toolbox/File/src/PhpFile.php(31): RocketTheme\Toolbox\File\File->save(Array) #3 /Users/akurczych/Sites/grav/system/src/Grav/Common/File/CompiledFile.php(67): RocketTheme\Toolbox\File\PhpFile->save(Array) #4 /Users/akurczych/Sites/grav/system/src/Grav/Common/Config/Setup.php(178): Grav\Common\File\CompiledYamlFile->content() #5 /Users/akurczych/Sites/grav/system/src/Grav/Common/Processors/SiteSetupProcessor.php(18): Grav\Common\Config\Setup->init() # in /Users/akurczych/Sites/grav/system/src/Grav/Common/File/CompiledFile.php on line 83

Apache runs with user akurczych

Permissions in the grav folder

-rw-rw-r--@  1 akurczych  staff   91404  7 Sep 14:09 CHANGELOG.md
-rw-rw-r--@  1 akurczych  staff    3216  7 Sep 14:09 CODE_OF_CONDUCT.md
-rw-rw-r--@  1 akurczych  staff    7061  7 Sep 14:09 CONTRIBUTING.md
-rw-rw-r--@  1 akurczych  staff    1071  7 Sep 14:09 LICENSE.txt
-rw-rw-r--@  1 akurczych  staff   14765  7 Sep 14:09 README.md
drwsrwsr-x@  3 akurczych  staff     102  7 Sep 14:09 assets
drwsrwsr-x@  3 akurczych  staff     102  7 Sep 14:09 backup
drwsrwsr-x@  6 akurczych  staff     204  7 Sep 14:09 bin
drwsrwsr-x@  3 akurczych  staff     102  7 Sep 14:09 cache
-rw-rw-r--@  1 akurczych  staff    1846  7 Sep 14:09 composer.json
-rw-rw-r--@  1 akurczych  staff  120320  7 Sep 14:09 composer.lock
drwsrwsr-x@  3 akurczych  staff     102  7 Sep 14:09 images
-rw-rw-r--@  1 akurczych  staff    1545  7 Sep 14:09 index.php
drwsrwsr-x@  3 akurczych  staff     102  7 Sep 14:09 logs
-rw-rw-r--   1 akurczych  staff     172 27 Sep 23:49 perm-fix.sh
-rw-rw-r--@  1 akurczych  staff     197  7 Sep 14:09 robots.txt
-rw-r--r--   1 akurczych  staff      19 27 Sep 23:56 setup.php
drwsrwsr-x@ 12 akurczych  staff     408 27 Sep 23:45 system
drwsrwsr-x@  3 akurczych  staff     102  7 Sep 14:09 tmp
drwsrwsr-x@  8 akurczych  staff     272  7 Sep 14:09 user
drwsrwsr-x@ 22 akurczych  staff     748  7 Sep 14:09 vendor
drwsrwsr-x@  8 akurczych  staff     272  7 Sep 14:09 webserver-configs

Any advice would be appreciated.

Thanks
Andy

Hi,
Your files must belong to the user of the web server (usually www-data).
To make yourself a chown www-data:www-data -R in your folder.

Could not change owner to www-data. Replied that it is illegal group name.

I checked which user Apache runs with using the following command

ps aux | grep -v root | grep apache | cut -d\ -f1 | sort | uniq

as recommended in the Troubleshooting Permissions section and it was akurczych so I thought that Apache runs with the same user as the owner of the files.

Check your apache configuration file, the user, and the group. But apparently it is the right user.
Finally, I say that, but I do not know if your hoster does not allow you to access this file.

The rights in the cache folder, are they the same?

To try, the time of a test can be, switch the right in 777 (read and write for all) in the cache folder, to see what it says, and after reset with correct rights after.

Hi Kosnik,

Finally got it sorted. You were right, it was a problem with user and group in the apache configuration file.

When I run the check suggested in the Permission troubleshooting section:

ps aux | grep -v root | grep apache | cut -d\ -f1 | sort | uniq

it showed that apache runs with akurczych user as required.

However following your advice and the advice in the apache set-up article https://getgrav.org/blog/macos-sierra-apache-multiple-php-versions
I realised that user and group need to be specified in the configuration file.

Thank you for your help. Much appreciated.

Best Regards,
Andy

You can then mark this as solved :wink:

1 Like