zoukankan      html  css  js  c++  java
  • zabbix3.0安装之图形界面显示异常【server】

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

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

    1 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"
    2 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里面看看:

    1 ; Limits the extensions of the main script FPM will allow to parse. This can
    2 ; prevent configuration mistakes on the web server side. You should only limit
    3 ; FPM to .php extensions to prevent malicious users to use other extensions to
    4 ; exectute php code.
    5 ; Note: set an empty value to allow all extensions.
    6 ; Default Value: .php
    7 ;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:

     1 server {
     2         listen 81;
     3         server_name localhost;
     4 
     5         location / {
     6             root           /usr/local/nginx/html/zabbix;
     7             fastcgi_pass   127.0.0.1:9000;
     8             fastcgi_index  index.php;
     9             fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    10             include        fastcgi_params;
    11         }
    12 
    13     }

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

    /usr/local/nginx/html/zabbix

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

     1 server {
     2         listen 81;
     3         server_name localhost;
     4 
     5         location ~ .php$ {
     6             root           /usr/local/nginx/html/zabbix;
     7             fastcgi_pass   127.0.0.1:9000;
     8             fastcgi_index  index.php;
     9             fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    10             include        fastcgi_params;
    11         }
    12 
    13         location ~* ^.+.(ico|gif|jpg|jpeg|png|html|css|htm|bmp|js|svg)$ {
    14            root           /usr/local/nginx/html/zabbix;
    15         }
    16 
    17     }

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

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

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

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

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

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

  • 相关阅读:
    HDU4529 郑厂长系列故事——N骑士问题 —— 状压DP
    POJ1185 炮兵阵地 —— 状压DP
    BZOJ1415 聪聪和可可 —— 期望 记忆化搜索
    TopCoder SRM420 Div1 RedIsGood —— 期望
    LightOJ
    LightOJ
    后缀数组小结
    URAL
    POJ3581 Sequence —— 后缀数组
    hdu 5269 ZYB loves Xor I
  • 原文地址:https://www.cnblogs.com/shihuc/p/6149253.html
Copyright © 2011-2022 走看看