我有一台运行CentOS和NGINX /
PHP-FPM的VPS.一切正常,除非我添加以下行以启用静态缓存内容.如果我这样做,页面不会加载指定的文件以保持缓存.
location ~* \.(ico|css|js|gif|jpg|jpeg|png)${ expires 30d; add_header Vary Accept-Encoding; access_log off; }
这是我的整个服务器{}:
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; } }
有谁知道为什么?
更新(解决方案):
正如Michael Hampton回答我的那样,服务器{}没有声明根,所以我按照说明将其添加到文件中.工作得很好!
您的服务器块没有定义根指令.相反,它似乎位于您的一个位置块中.这是
the most common nginx mistakes之一.将其移到服务器块下.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。