I’m running a grav on wordops which is a basic PHP setup which keeps going down (blank page 500 or 503 I think). After resetting the permissions back as per the permissions reset script below and all is well again for a little while, then it happens again. I did suspect it was because php-fpm is running as root, but after more testing it looks like it is scheduler changing the permissions. As below, you can see that www-data does not have write permissions after scheduler has run.
-rw-r--r-- 1 botanica www-data 244584 May 26 05:01 master-localhost.php
Have I set this up wrong? Is there a correct way? DO I have to run crontab as www-data user?
Reset Script
chown -R www-data:www-data .
find . -type f -exec chmod 664 {} \;
find ./bin -type f -exec chmod 775 {} \;
find . -type d -exec chmod 775 {} \;
find . -type d -exec chmod +s {} \;
Errors
: PHP Fatal error: Uncaught RuntimeException: Failed to save file /var/www/botanicalhealing.co.za/htdocs/cache/compiled/blueprints/master-botanicalhealing.co.za.php in /var/www/botanicalhealing.co.za/htdocs/vendor/rockettheme/toolbox/File/src/File.php:351
Stack trace:
#0 /var/www/botanicalhealing.co.za/htdocs/vendor/rockettheme/toolbox/File/src/PhpFile.php(31): RocketTheme\Toolbox\File\File->save(Array)
#1 /var/www/botanicalhealing.co.za/htdocs/system/src/Grav/Common/Config/CompiledBase.php(252): RocketTheme\Toolbox\File\PhpFile->save(Array)
#2 /var/www/botanicalhealing.co.za/htdocs/system/src/Grav/Common/Config/CompiledBase.php(117): Grav\Common\Config\CompiledBase->saveCompiledFile('/var/www/botani...')
#3 /var/www/botanicalhealing.co.za/htdocs/system/src/Grav/Common/Service/ConfigServiceProvider.php(77): Grav\Common\Config\CompiledBase->load()
#4 /var/www/botanicalhealing.co.za/htdocs/system/src/Grav/Common/Service/ConfigServiceProvider.php(36): Grav\Common\Service\ConfigServiceProv" while reading response header from upstream, client: 183.136.225.46, server: botanicalhealing.co.za, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php73-fpm.sock:", host: "botanicalhealing.co.za"
2020/05/24 00:10:10 [error] 2043#2043: *654 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught RuntimeException: Failed to save file /var/www/botanicalhealing.co.za/htdocs/cache/compiled/blueprints/master-botanicalhealing.co.za.php in /var/www/botanicalhealing.co.za/htdocs/vendor/rockettheme/toolbox/File/src/File.php:351
Other mentions of the same problem with no solution and my thread on WordOps community.