前面記錄過Zabbix3.0的安裝過程,遇到一些坑,當時就在博文最後提到過,顯示界面只有文字沒有樣式的問題。今天就解決這個小問題。php
首先, 咱們的安裝是基於nginx做爲web服務器的,不是傳統的用Apache做爲服務器,出現樣式顯示異常,能夠從nginx的日誌中查看信息,找緣由,這個一般可以解決大部分可能的問題。css
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裏面看看:html
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頁面上仍是看不到樣式,只是純文字。。。。nginx
在瀏覽器裏面看頁面源碼,樣式文件都加載了,可是就是沒有被解析出來,說明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:web
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,一切都看上去漂亮起來了。【參考下面的截圖】ide
這個圖中的錯誤,很簡單就能夠搞定,按照提示,下載文件並保存到/usr/local/nginx/html/zabbix/conf/zabbix.conf.php便可。svg
注意, Zabbix默認的用戶名和密碼是Admin/zabbix (注意,用戶名首字母大寫的喲)
當前沒有安裝agent,因此,系統中什麼監控信息也沒有。
如今眼前的世界,是否是一切都美好了