I'm running a grav site which is a basic PHP setup which keeps going down (blank page 503 I think) . I reset the permissions back as per the permissions reset script below and all is well again for a little while, then it happens again. Suspect it is because php-fpm is running as root. Should php be running as root or is there another problem / solution here?
Current owners php ps aux | grep php-fpm)
root 678 0.0 2.1 423040 42100 ? Ss May22 0:17 php-fpm: master process (/etc/php/7.3/fpm/php-fpm.conf)
root 64562 0.0 0.0 6076 816 pts/1 S+ 12:30 0:00 grep php-fpm
Current owners nginx (ps aux | grep nginx)
root 56661 0.0 0.7 183844 15088 ? Ss 12:02 0:00 nginx: master process /usr/sbin/nginx
www-data 56740 0.0 1.8 467152 36660 ? Sl 12:02 0:00 nginx: worker process
www-data 56742 0.0 0.6 184172 12320 ? S 12:02 0:00 nginx: cache manager process
root 64574 0.0 0.0 6076 824 pts/1 S+ 12:31 0:00 grep nginx
Permissions 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
Site Info
wo site info botanicalhealing.co.za
Information about botanicalhealing.co.za (domain):
Nginx configuration php basic (enabled)
PHP Version 7.3
SSL enabled
SSL PROVIDER Lets Encrypt
SSL EXPIRY DATE 86
access_log /var/www/botanicalhealing.co.za/logs/access.log
error_log /var/www/botanicalhealing.co.za/logs/error.log
Webroot /var/www/botanicalhealing.co.za
Root owned files when I have the problem
find /var/www/botanicalhealing.co.za/htdocs/ -user root
/var/www/botanicalhealing.co.za/htdocs/logs/backup.log
/var/www/botanicalhealing.co.za/htdocs/user/data/scheduler/status.yaml
/var/www/botanicalhealing.co.za/htdocs/backup/default_site_backup--20200523030002.zip
/var/www/botanicalhealing.co.za/htdocs/backup/default_site_backup--20200524030002.zip
/var/www/botanicalhealing.co.za/htdocs/cache/compiled/files
/var/www/botanicalhealing.co.za/htdocs/cache/compiled/files/b7953f24459e85a3c7324e7d350fdb17.yaml.php
/var/www/botanicalhealing.co.za/htdocs/cache/compiled/files/23403e388811a59c777721e3046f507b.yaml.php