http://jingyan.baidu.com/article/a3f121e4cb684afc9152bb73.htmljavascript
依賴包安裝php
# yum -y install net-snmp net-snmp-devel perl-DBI php-gd php-xml php-bcmath fping OpenIPMI-devel php-mbstring
1.將源碼中的zabbix-3.0.4/database/mysql 下的sql文件導入zabbix數據庫(必須按照如下順序到入)html
首先建立名爲 zabbix 的數據庫
mysql> create database zabbix default character set utf8; # tar -xvzf zabbix-3.0.4.tar.gz # cd zabbix-3.0.4 # /usr/local/mysql/bin/mysql -u root -h localhost zabbix < schema.sql # /usr/local/mysql/bin/mysql -u root -h localhost zabbix < images.sql # /usr/local/mysql/bin/mysql -u root -h localhost zabbix < data.sql
# groupadd zabbix # useradd -g zabbix zabbix
# ./configure --prefix=/usr/local/zabbix/ --enable-server --enable-agent --with-mysql --with-net-snmp
安裝zabbix提示:
checking for net-snmp-config... no configure: error: Invalid Net-SNMP directory - unable to find net-snmp-config 解決方案: # yum install net-snmp-devel -y
ListenPort=10051
LogFile=/tmp/zabbix_server.log
DBHost=localhost
DBName=zabbix
DBUser=root #我直接用root用戶做爲zabbix數據庫的用戶,且沒有設置密碼
ListenIP=127.0.0.1前端
# /usr/local/zabbix/sbin/zabbix_server 啓動時報錯: Starting zabbix_server: /usr/local/zabbix/sbin/zabbix_server: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory 解決方案: # locate libmysqlclient.so.18 # echo "/usr/local/mysql/lib" >> /etc/ld.so.conf # ldconfig
若要web界面的支持,則須要Nginx(須要php-fpm)和PHP的支持,安裝方法參見文章開頭的傳送鏈接。Nginx和PHP安裝完成後,進行以下操做。java
# cd zabbix-3.0.4/frontends/php # mkdir /usr/local/nginx/html/zabbix/ # cp -a . /usr/local/nginx/html/zabbix/ 啓動nginx和php-fpm # /usr/local/nginx/sbin/nginx # /usr/local/php/sbin/php-fpm -c /usr/local/php/etc/php.ini
在安裝PHP時,必定要看清Zabbix的官方文檔上給出的 Requirements,不然在編譯安裝PHP時會漏掉不少支持組件的信息,致使沒法順利的在web界面配置Zabbix前端。mysql
如下是我所踩過的坑:linux
相似出現:PHP option "post_max_size" 8M 16M Fail 等 須要更改php.ini文件,可是在安裝PHP時須要指定php的配置文件的存放位置,如個人指定爲: --with-config-file-path=/usr/local/php/etc 而後將源碼裏面的php.ini-production 拷貝到/usr/local/php/etc/php.ini 注意:在編譯安裝完成php後,配置完成啓動php-fpm時,直接執行/usr/local/php/sbin/php-fpm 雖然可 以啓動,可是這樣的話,php.ini文件是沒有生效的,這就會致使即便你更改了php.ini裏面的參數,Zabbix前端檢測依然沒法經過。解決方法是按照如下方式啓動php-fpm: # /usr/local/php/sbin/php-fpm -c /usr/local/php/etc/php.ini
PHP bcmath off Fail --enable-bcmath PHP mbstring off Fail --enable-mbstring PHP sockets off Fail --enable-sockets等 這些錯誤只要在安裝PHP時加上對應選項便可,如:--enable-bcmath
PHP databases support off Fail --with-mysql=/usr/local/mysql 解決方案: 這種錯誤是提示不支持MySQL,可是咱們在編譯安裝時是指定了的,爲什麼出錯了?由於更新後的PHP版本,如今須要mysqli的支持才能行,mysqli是對mysql函數(注意這裏指的是PHP中的函數)的優化,所以咱們須要安裝進入PHP源碼中的mysqli目錄下就可安裝,方法以下: # cd php-5.6.25/ext/mysqli/ # phpize # ./configure --with-php-config=/usr/local/php/bin/php-config --with-mysqli=/usr/local/mysql/bin/mysql_config # make && make install # cd /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226 # ls 若是有mysqli.so文件,就說名安裝好了。 接着編輯php配置文件 /usr/local/php/etc/php.ini,加入extension=mysqli.so(能夠寫全路徑) 在make && make install時出現: /root/soft/php-5.6.25/ext/mysqli/mysqli_api.c:36:47: error: ext/mysqlnd/mysql_float_to_double.h: No such file or directory make: *** [mysqli_api.lo] Error 1 解決方法:編輯mysqli_api.c,而後註釋掉mysql_float_to_double.h這個頭文件(講真,我不知道這樣作會有什麼後果)
PHP gd JPEG support off Fail --with-jpeg-dir=DIR GD: Set the path to libjpeg install prefix 解決方案:編譯安裝jpeg # wget http://www.ijg.org/files/jpegsrc.v9b.tar.gz # mkdir /usr/local/jpeg # ./configure --prefix=/usr/local/jpeg --enable-shared PHP gd PNG support off Fail --with-png-dir=DIR GD: Set the path to libpng install prefix 解決方案:編譯安裝libpng # wget http://prdownloads.sourceforge.net/libpng/libpng-1.6.24.tar.gz?download # mkdir /usr/local/libpng # ./configure --prefix=/usr/local/libpng 要編譯 GD 庫,須要libpng 和 libjpeg(前面已經安裝了) PHP gd unknown 2.0 Fail --with-gd=DIR Include GD support. DIR is the GD library base install directory BUNDLED 解決方案:進入PHP源碼的ext/gd目錄下編譯安裝GD庫 # yum install gd-devel # cd php-5.6.8/ext/gd # phpize # ./configure --with-jpeg-dir=/usr/local/jpeg --with-php-config=/usr/local/php/bin/php-config 提示:configure: error: png.h not found. 解決:# yum install libpng-devel # make clean # make install 我在編譯php時執行源碼安裝的 gd(/usr/local/gd)目錄,編譯就不能經過。直接加--with-gd就行(我懷疑是我用yum安裝了 gd-devel的緣故) PHP gd FreeType support off Fail --with-freetype-dir=DIR GD: Set the path to FreeType 2 install prefix 解決方案:編譯安裝FreeType # wget https://sourceforge.net/projects/freetype/files/freetype2/2.6.5/freetype-2.6.5.tar.gz/download # mkdir /usr/local/freetype # ./configure --prefix=/usr/local/freetype/ # make && make install PHP gettext off Warning --with-gettext=DIR Include GNU gettext support 解決方案: # wget http://ftp.gnu.org/pub/gnu/gettext/gettext-0.19.tar.gz # mkdir /usr/local/gettext # ./configure --prefix=/usr/local/gettext
所以爲了支持Zabbix前端,編譯安裝PHP時須要如下選項:nginx
--prefix=/usr/local/php \ --with-mysql=/usr/local/mysql \ --enable-fastcgi \ --enable-fpm \ --with-config-file-path=/usr/local/php/etc \ -with-zlib=/usr/local/zlib \ --enable-bcmath \ --enable-mbstring \ --enable-sockets \ --with-gettext=/usr/local/gettext \ --with-jpeg-dir=/usr/local/jpeg \ --with-png-dir=/usr/local/libpng \ --with-freetype-dir=/usr/include/freetype2/freetype \ --with-gd
注意:web