前面记录过Zabbix3.0的安装过程,遇到一些坑,当时就在博文最后提到过,显示界面只有文字没有样式的问题。今天就解决这个小问题。

首先, 我们的安装是基于nginx作为web服务器的,不是传统的用Apache作为服务器,出现样式显示异常,可以从nginx的日志中查看信息,找原因,这个通常能够解决大部分可能的问题。

 // :: [error] #: * 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"
// :: [error] #: * 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:

 server {
listen ;
server_name localhost; location / {
root /usr/local/nginx/html/zabbix;
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
} }

到这里,是不是很清楚了,问题发生在什么地方? 这个是说,静态资源文件等所有的url请求都被转发给php-fpm这个服务上了,就是127.0.0.1:9000对应的应用上了,但是呢,zabbix的静态页面文件,主要是css,js,image等,php-fpm其实是不知道的,这个资源文件其实在下面的目录里:

/usr/local/nginx/html/zabbix

原来,问题在URL资源解析路径错了,这个错根本原因错在配置上,nginx的配置错了。需要给静态资源配置一个解析规则,即添加一个location的匹配规则即可轻松的解决这个问题:

 server {
listen ;
server_name localhost; location ~ \.php$ {
root /usr/local/nginx/html/zabbix;
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
} location ~* ^.+\.(ico|gif|jpg|jpeg|png|html|css|htm|bmp|js|svg)$ {
root /usr/local/nginx/html/zabbix;
}

}

将nginx重新加载一下
[root@CloudGame conf]# ./../sbin/nginx -s reload

刷新页面,ok,一切都看上去漂亮起来了。【参考下面的截图】

这个图中的错误,很简单就可以搞定,按照提示,下载文件并保存到/usr/local/nginx/html/zabbix/conf/zabbix.conf.php即可。

注意, Zabbix默认的用户名和密码是Admin/zabbix (注意,用户名首字母大写的哟)

当前没有安装agent,所以,系统中什么监控信息也没有。

现在眼前的世界,是不是一切都美好了

最新文章

  1. thinkphp 命名空间
  2. js中逻辑为false的8种情况
  3. SQL语句技巧:查询存在一个表而不在另一个表中的数据记录
  4. CListCtrl使用方法汇总
  5. 两个Activity之间的交互startActivityForResult的使用
  6. DM8168 DVRRDK软件框架研究
  7. Swift与Objective-C的兼容“黑魔法”:@objc和Dynamic
  8. WebApi2官网学习记录---异常处理
  9. Directx11学习笔记【九】 【转】 3D渲染管线
  10. Camera测试之Color & Lens shading Test
  11. Vue-computed的set和get
  12. 单行显示三级分销记录(同表自join)
  13. 代码块事务—TransactionScope
  14. mysql解压缩版安装方法以及mysql无法启动1067错误
  15. Zookeeper Windows版的服务安装和管理工具
  16. 【POJ1734】Sightseeing Trip 无向图最小环
  17. 洛谷P1164 小A点菜 DP入门
  18. angularjs探秘<二>表达式、指令、数据绑定
  19. git commit如何修改默认编辑器为vim
  20. redis服务启动脚本

热门文章

  1. Hello World!
  2. NOIP 考前 并查集复习
  3. JAVA学习遇到的问题:接口实现
  4. void 关键字
  5. 黑马程序员:Java编程_7K面试题之银行业务调度系统
  6. Reconstruct Itinerary
  7. 关于rem的自定义HTML比例设定
  8. gcc编译的四个阶段:预处理,编译,汇编,链接
  9. iOS不使用JSONKit做Dic到JsonString的转换
  10. 图片在ie8浏览器打不开,其他浏览器都可以打开的问题