2016/11/18 12:50:43 [error] 6664#0: *447 FastCGI sent in stderr: "Access to the script '/usr/local/nginx/html/zabbix/styles/blue-theme.css' has been denied (see security.limit_extensions)" while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /styles/blue-theme.css HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost:81", referrer: "http://localhost:81/setup.php"
2016/11/18 12:50:43 [error] 6664#0: *447 FastCGI sent in stderr: "Access to the script '/usr/local/nginx/html/zabbix/js/browsers.js' has been denied (see security.limit_extensions)" while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /js/browsers.js HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost:81", referrer: "http://localhost:81/setup.php"
有这么个fastCGI的错误,提示检查security.limit_extensions,说明这个有点配置问题,这个是网络相关的配置,我们去/etc/php-fpm.d/www.conf里面看看:
; Limits the extensions of the main script FPM will allow to parse. This can
; prevent configuration mistakes on the web server side. You should only limit
; FPM to .php extensions to prevent malicious users to use other extensions to
; exectute php code.
; Note: set an empty value to allow all extensions.
; Default Value: .php
;security.limit_extensions = .php .php3 .php4 .php5
看到没有,这里是有问题的,我们的样式以及js,扩展名没有在这里放行。。。将其修改成下面的样子:
security.limit_extensions = .php .php3 .php4 .php5 .js .css .jpg .gif .png .jpeg .html .ico .bmp
重启php-fpm,nginx后台错误日志里面不再有上面类似FastCGI sent in stderr: "Access to the script。。。这样子的错误了,但是web页面上还是看不到样式,只是纯文字。。。。
在浏览器里面看页面源码,样式文件都加载了,但是就是没有被解析出来,说明mime出了问题,回过头看看nginx的配置,应该是这里有问题。
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost:81/styles/blue-theme.css".
这个应该是php-fpm的解析出了问题,想想,静态文件,没有必要让php-fpm进行处理,直接nginx返回就好!看看nginx的location: