这是我的网站虚拟主机指令 它位于 /etc/nginx/conf.d/site1.conf:
fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=WORDPRESS:100m inactive=900m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
server {
listen 80;
server_name mysite.com www.mysite.com;
root /var/www/mysite.com/public_html;
index index.html index.htm index.php;
error_log /var/www/mysite.com/public_html/error.log error;
location / {
try_files $uri $uri/ /index.php?$args;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
add_header X-Cache $upstream_cache_status;
fastcgi_cache_use_stale error timeout invalid_header http_500;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
fastcgi_cache WORDPRESS;
fastcgi_cache_valid 300m;
include fastcgi_params;
}
}
我的cadhe适用于mysite.com
但是,当我要将缓存添加到其他站点时,请说site2.com.conf
fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=WORDPRESS:100m; inactive=900m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
server {
...
}
我说一个错误
nginx: [emerg] the same path name "/var/run/nginx-cache" used in /etc/nginx/conf.d/site.com.conf:1 and in /etc/nginx/conf.d/site2.com.conf:1
我记得我曾经在另一个Nginx中做得很好。也许我有批量包含.conf文件的nginx指令?