Suddenly I started getting the following error when I try to restart nginx:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: [emerg] mkdir() "/var/run/nginx-cache/site1" failed (2: No such file or directory)
nginx: configuration file /etc/nginx/nginx.conf test failed
So I have to create nginx-cache folder and make www-data the owner of it to restart nginx, but I'm hoping there's a better way.
For your information, my nginx configuration is as follows:
fastcgi_cache_path /var/run/nginx-cache/site1 levels=1:2 keys_zone=site1:100m inactive=60m;
fastcgi_cache_path /var/run/nginx-cache/site2 levels=1:2 keys_zone=site2:100m inactive=60m;
fastcgi_cache_path /var/run/nginx-cache/site3 levels=1:2 keys_zone=site3:100m inactive=60m;
fastcgi_cache_use_stale error timeout invalid_header http_500;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
server {
....
location ~ \.php$ {
....
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
fastcgi_cache site1;
fastcgi_cache_valid 60m;
}
server {
....
location ~ \.php$ {
....
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
fastcgi_cache site2;
fastcgi_cache_valid 60m;
}
server {
....
location ~ \.php$ {
....
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
fastcgi_cache site3;
fastcgi_cache_valid 60m;
}
Any help would be greatly appreciated!