I know this is a common problem. i’ve read multiple posts about it, but none of them worked for me.
I have a fresh install of Grav running locally, just to test it. It is running over Nginx.
When i start it over nginx, with a custom server_name, it gives-me a blank page. by going on localhost, i am met with the error " InvalidArgumentException
The directory “/var/www/html/grav/cache/doctrine/9565bf08” does not exist and could not be created.".
I dont think the problem is with nginx. i created a php.php and a index2.html to test it and it works.
on the other hand, when i use the grav bult-in web server, it runs perfectly.
what is wrong?
here is my nginx conf
server {
index index.html index.php;
root /var/www/html/grav;
server_name grav.localhost;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~* /(\.git|cache|bin|logs|backup|tests)/.*$ { return 403; }
location ~* /(system|vendor)/.*\.(txt|xml|md|html|htm|shtml|shtm|json|yaml|yml|php|php2|php3|php4|php5|phar|phtml|pl|py|cgi|twig|sh|bat)$ { return 403; }
location ~* /user/.*\.(txt|md|json|yaml|yml|php|php2|php3|php4|php5|phar|phtml|pl|py|cgi|twig|sh|bat)$ { return 403; }
location ~ /(LICENSE\.txt|composer\.lock|composer\.json|nginx\.conf|web\.config|htaccess\.txt|\.htaccess) { return 403; }
location ~ \.php$ {
include /etc/nginx/default.d/*.conf;
}
}
q3d
November 20, 2024, 9:15pm
2
The issue you’re experiencing is likely related to directory permissions. The error message indicates that the server cannot create the required directory under /var/www/html/grav/cache/doctrine
.
To resolve this, first check and update the permissions for the cache
directory and its parent directories.
i chmod the whole /www/html/grav folder to 777. the problem persists.
as i said, it works with the built-in webserver, but not with nginx, for some reason.
and even that error, it only appears on localhost, but the server_name i assigned is grav.localhost, which is blank
this is the nginx log. as i said, it is all 777, and chown is $USER:nginx
2024/11/21 14:05:55 [error] 107791#107791: *56 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught RuntimeException: Failed to save file /var/www/html/grav/cache/compiled/blueprints/master-grav.localhost.php in /var/www/html/grav/vendor/rockettheme/toolbox/File/src/AbstractFile.php:374
Stack trace:
#0 /var/www/html/grav/vendor/rockettheme/toolbox/File/src/PhpFile.php(46): RocketTheme\Toolbox\File\AbstractFile->save()
#1 /var/www/html/grav/system/src/Grav/Common/Config/CompiledBase.php(255): RocketTheme\Toolbox\File\PhpFile->save()
#2 /var/www/html/grav/system/src/Grav/Common/Config/CompiledBase.php(113): Grav\Common\Config\CompiledBase->saveCompiledFile()
#3 /var/www/html/grav/system/src/Grav/Common/Service/ConfigServiceProvider.php(106): Grav\Common\Config\CompiledBase->load()
#4 /var/www/html/grav/system/src/Grav/Common/Service/ConfigServiceProvider.php(46): Grav\Common\Service\ConfigServiceProvider::blueprints()
#5 /var/www/html/grav/vendor/pimple/pimple/src/Pimple/Container.php(122): Grav\Common\Service\ConfigServiceProvider->Grav\Common\Service\{clos" while reading response header from upstream, client: 127.0.0.1, server: grav.localhost, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm/www.sock:", host: "grav.localhost", referrer: "http://grav.localhost/"
2024/11/21 14:17:50 [error] 107792#107792: *59 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught RuntimeException: Failed to save file /var/www/html/grav/cache/compiled/blueprints/master-grav.localhost.php in /var/www/html/grav/vendor/rockettheme/toolbox/File/src/AbstractFile.php:374
Stack trace:
#0 /var/www/html/grav/vendor/rockettheme/toolbox/File/src/PhpFile.php(46): RocketTheme\Toolbox\File\AbstractFile->save()
#1 /var/www/html/grav/system/src/Grav/Common/Config/CompiledBase.php(255): RocketTheme\Toolbox\File\PhpFile->save()
#2 /var/www/html/grav/system/src/Grav/Common/Config/CompiledBase.php(113): Grav\Common\Config\CompiledBase->saveCompiledFile()
#3 /var/www/html/grav/system/src/Grav/Common/Service/ConfigServiceProvider.php(106): Grav\Common\Config\CompiledBase->load()
#4 /var/www/html/grav/system/src/Grav/Common/Service/ConfigServiceProvider.php(46): Grav\Common\Service\ConfigServiceProvider::blueprints()
#5 /var/www/html/grav/vendor/pimple/pimple/src/Pimple/Container.php(122): Grav\Common\Service\ConfigServiceProvider->Grav\Common\Service\{clos" while reading response header from upstream, client: 127.0.0.1, server: grav.localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm/www.sock:", host: "grav.localhost"