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,所以,系統中什么監控信息也沒有。

 

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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM