Eri*_*edo 4 nginx centos php-fpm
我有一个运行 CentOS 和 NGINX/PHP-FPM 的 VPS。一切正常,除非我添加以下几行以启用静态缓存内容。如果我这样做,该页面不会加载那些指定保留缓存的文件。
location ~* \.(ico|css|js|gif|jpg|jpeg|png)$ {
expires 30d;
add_header Vary Accept-Encoding;
access_log off;
}
Run Code Online (Sandbox Code Playgroud)
这是我的整个服务器{}:
server {
listen 80;
server_name mywebsite.com www.mywebsite.com;
#location ~* \.(ico|css|js|gif|jpg|jpeg|png)$ {
# expires 30d;
# add_header Vary Accept-Encoding;
# access_log off;
#}
location / {
if ($http_host ~* "^www.(.*)$"){
set $rule_0 1$rule_0;
set $bref_1 $1;
}
if ($rule_0 = "1"){
rewrite ^/(.*)$ http://$bref_1/$1 permanent;
}
rewrite ^/search/(.*)/(.*)/?$ /index.php?search=$1&page=$2&type=mp3 las$
rewrite ^/(.*)/(.*)/(.*)?$ /index.php?search=$1&page=$2&type=$3 last;
root /var/www/mywebsite.com/public_html;
index index.php index.html index.htm;
}
location ~ \.php$ {
fastcgi_read_timeout 300;
root /var/www/mywebsite.com/public_html;
fastcgi_pass unix:/tmp/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Run Code Online (Sandbox Code Playgroud)
有谁知道为什么?
更新(解决方案):
当 Michael Hampton 回答我时,服务器没有声明根,因此我按照说明将其添加到文件中。{} 工作得很好!
归档时间: |
|
查看次数: |
1372 次 |
最近记录: |