一、下載安裝包並解壓
二、預環境搭建
三、建立zabbix用戶,編譯安裝zabbix
四、配置mysql
五、配置zabbix-server
六、配置apache和php
七、添加開機自啓動
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
1 yum install wget -y 2 wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.0.3/zabbix-4.0.3.tar.gz 3 tar -zxf zabbix-4.0.3.tar.gz 4 cd zabbix-4.0.3 5 6 yum -y install httpd mysql-server 7 rpm -i https://mirror.webtatic.com/yum/el6/latest.rpm 8 yum -y install php55w php55w-mysql php55w-cli php55w-xml php55w-gd php55w-common php55w-bcmath php55w-pdo php55w-mbstring 9 yum -y install gcc mysql-devel libxml2-devel net-snmp-devel libevent-devel libcurl-devel pcre-devel 10 11 useradd zabbix -s /sbin/nologin -M -u 200 12 ./configure --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 13 make install 14 15 /etc/init.d/mysqld start 16 mysql 17 create database zabbix4 character set utf8; 18 grant all on zabbix4.* to 'zbxuser'@'10.0.0.%' identified by 'zbxpass'; 19 grant all on zabbix4.* to 'zbxuser'@'localhost' identified by 'zbxpass'; 20 flush privileges; 21 quit 22 mysql zabbix4 < ~/zabbix-4.0.3/database/mysql/schema.sql 23 mysql zabbix4 < ~/zabbix-4.0.3/database/mysql/images.sql 24 mysql zabbix4 < ~/zabbix-4.0.3/database/mysql/data.sql 25 26 sed "s/.*DBHost=.*/DBHost=localhost/g" /usr/local/etc/zabbix_server.conf -i 27 sed "s/^DBName=.*/DBName=zabbix4/g" /usr/local/etc/zabbix_server.conf -i 28 sed "s/^DBUser=.*/DBUser=zbxuser/g" /usr/local/etc/zabbix_server.conf -i 29 sed "s/.*DBPassword=.*/DBPassword=zbxpass/g" /usr/local/etc/zabbix_server.conf -i 30 zabbix_server 31 32 \cp -r ~/zabbix-4.0.3/frontends/php /var/www/html/zabbix 33 \cp /etc/php.ini{,.bak} 34 sed -i '/post_max_size =/ s/=.*M$/= 16M/g' /etc/php.ini 35 sed -i '/max_execution_time =/ s/=.*/= 300/g' /etc/php.ini 36 sed -i '/max_input_time =/ s/=.*/= 300/g' /etc/php.ini 37 sed -i '/date.timezone =/ adate.timezone = Asia/Shanghai' /etc/php.ini 38 chown -R apache. /var/www/html/zabbix/conf/ 39 /etc/init.d/httpd restart 40 zabbix_agentd 41 42 chkconfig httpd on 43 chkconfig mysqld on 44 echo "/usr/local/sbin/zabbix_server" >>/etc/rc.local 45 echo "/usr/local/sbin/zabbix_agentd" >>/etc/rc.local 46 netstat -lntp
一、下載安裝包並解壓
# 安裝wget yum install wget -y # 下載zabbix源碼包 wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.0.3/zabbix-4.0.3.tar.gz # 解壓縮並切換到zabbix-4.0.3目錄下 tar -zxf zabbix-4.0.3.tar.gz cd zabbix-4.0.3
二、預環境搭建
# 安裝lamp環境(3.x以上版本的zabbix須要5.4以上版本的php支持,CentOS6默認yum源php最高版本爲php5.3) # 安裝apache和mysql-server yum -y install httpd mysql-server # 安裝高版本php的yum源 rpm -i https://mirror.webtatic.com/yum/el6/latest.rpm # 安裝php5.5 yum -y install php55w php55w-mysql php55w-cli php55w-xml php55w-gd php55w-common php55w-bcmath php55w-pdo php55w-mbstring # 安裝所需的編譯工具或相關類庫 yum -y install gcc mysql-devel libxml2-devel net-snmp-devel libevent-devel libcurl-devel pcre-devel
三、建立zabbix用戶,編譯安裝zabbix
# 建立zabbix用戶用以啓動相關進程 useradd zabbix -s /sbin/nologin -M -u 200 # 配置zabbix須要安裝的功能 ./configure --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 # 安裝 make install
四、配置mysql
# 啓動mysqld服務 /etc/init.d/mysqld start # 進入數據庫 mysql # 建立zabbix4數據庫 create database zabbix4 character set utf8; # 受權 grant all on zabbix4.* to 'zbxuser'@'10.0.0.%' identified by 'zbxpass'; grant all on zabbix4.* to 'zbxuser'@'localhost' identified by 'zbxpass'; # 更新配置使其實時生效 flush privileges; # 查看數據庫是否建立成功 show databases; # 退出 quit # 將zabbix的相關表導入到zabbix4數據庫中 mysql zabbix4 < ~/zabbix-4.0.3/database/mysql/schema.sql mysql zabbix4 < ~/zabbix-4.0.3/database/mysql/images.sql mysql zabbix4 < ~/zabbix-4.0.3/database/mysql/data.sql # 驗證 mysql zabbix4 show tables; quit
五、配置zabbix-server
# 配置DBHost sed "s/.*DBHost=.*/DBHost=localhost/g" /usr/local/etc/zabbix_server.conf -i # 配置DBName sed "s/^DBName=.*/DBName=zabbix4/g" /usr/local/etc/zabbix_server.conf -i # 配置DBUser sed "s/^DBUser=.*/DBUser=zbxuser/g" /usr/local/etc/zabbix_server.conf -i # 配置DBPassword sed "s/.*DBPassword=.*/DBPassword=zbxpass/g" /usr/local/etc/zabbix_server.conf -i # 查看配置更改狀況 cat /usr/local/etc/zabbix_server.conf |grep -E "DBHost=|DBName=|DBUser=|DBPassword=" # 啓動zabbix_server服務 zabbix_server # 查看zabbix_server是否啓動成功 netstat -lntp
六、配置apache和php
# 將前端文件拷貝到Apache響應目錄下 \cp -r ~/zabbix-4.0.3/frontends/php /var/www/html/zabbix # 配置php.ini \cp /etc/php.ini{,.bak} sed -i '/post_max_size =/ s/=.*M$/= 16M/g' /etc/php.ini sed -i '/max_execution_time =/ s/=.*/= 300/g' /etc/php.ini sed -i '/max_input_time =/ s/=.*/= 300/g' /etc/php.ini sed -i '/date.timezone =/ adate.timezone = Asia/Shanghai' /etc/php.ini cat /etc/php.ini |grep -E "post_max_size =|max_execution_time =|max_input_time =|date.timezone =" # 受權 chown -R apache. /var/www/html/zabbix/conf/ ls -ld /var/www/html/zabbix/conf/ # 啓動httpd /etc/init.d/httpd restart # 啓動zabbix_agentd zabbix_agentd # 查看服務啓動端口監聽狀況 netstat -lntp
七、添加開機自啓動
chkconfig httpd on
chkconfig mysqld on
echo "/usr/local/sbin/zabbix_server" >>/etc/rc.local
echo "/usr/local/sbin/zabbix_agentd" >>/etc/rc.local