Persistent Permissions Problem

I’m looking into using Grav for an upcoming project and thought I’d test it out with a VM on my PC. Easy, I thought. I am running CentOS 7 in a Virtualbox VM on an OS X host. I started out using nginx as the web server. The first problem I encountered was that the latest version of PHP in the default CentOS repos is not sufficient. So I enabled the IUS repos and installed PHP 7. Then I found out the mbstring PHP module wasn’t installed. I installed that along with the others in the Grav requirements doc. Still no luck. I’ve checked all the relevant pages in the Grav documentation regarding errors and permissions. But things weren’t working. So I tried PHP 5.6. Nope. I then rolled back the VM and started over with Apache and PHP 5.6. And I’m still getting the following error in my httpd logs when I browse to the grav installation directory (located at my DocumentRoot):

[Mon Sep 19 03:06:32.733879 2016] [:error] [pid 9805] [client 192.168.56.1:50922] PHP Fatal error: Uncaught exception ‘RuntimeException’ with message ‘Creating directory ‘/var/www/html/cache//compiled/fi les’ failed on error mkdir(): Permission denied’ in /var/www/html/vendor/rockettheme/toolbox/File/src/File.php:420
Stack trace:
#0 /var/www/html/vendor/rockettheme/toolbox/File/src/File.php(195): RocketTheme\Toolbox\File\File->mkdir (‘/var/www/html/c…’)
#1 /var/www/html/vendor/rockettheme/toolbox/File/src/File.php(316): RocketTheme\Toolbox\File\File->lock()
#2 /var/www/html/vendor/rockettheme/toolbox/File/src/PhpFile.php(31): RocketTheme\Toolbox\File\File->save(Array)
#3 /var/www/html/system/src/Grav/Common/File/CompiledFile.php(66): RocketTheme\Toolbox\File\PhpFile->save(Array)
#4 /var/www/html/system/src/Grav/Common/Config/Setup.php(178): Grav\Common\File\CompiledYamlFile->content()
#5 /var/www/html/system/src/Grav/Common/Processors/SiteSetupProcessor.php (17): Grav\Common\Config\Setup->init()
#6 /var/www/html/system/src/Grav/Common/Grav.php(121): Grav\Common\Processors\SiteSetupProcessor->process()
#7 /v in /var/www/html/vendor/rockettheme/toolbox/File/src/File.php on line 420

Please note that I’ve already checked a few things: First, the owner of the Grav directories and files is the same that runs the web server (apache). It was also the socket user when I was using nginx (php-fpm). All the files have the proper permissions for read/write/execute by the apache user. In fact, just to rule this kind of thing out, I gave full permissions to everyone (chmod 777) recursively to the document root to see if that would change results. Nope.

I’ve added the required PHP and Apache modules. I’ve created the phpinfo() test page within the same document root as Grav, and it works just fine. I’ve edited Grav’s .htaccess to toggle Options -Indexes and RewriteBase / together and separately. No dice.

I feel like it must be something basic that I’m missing here, but I’ve been through all the documentation, searched these forums and elsewhere and still can’t figure out why it’s not working. So any help would be much appreciated.

To update, I made a new VM using Ubuntu 16.04 LTS with Apache and everything worked like a charm, though for some reason Grav created a cache directory with root ownership that I had to chown for things to continue.

So I’m very curious as to why things didn’t work on CentOS.

It will create directories as needed with the user permissions of the webserver. Checke out this troubleshooting guide for more info on permissions.