1. 程式人生 > >原始碼安裝zabbix4.0.1

原始碼安裝zabbix4.0.1

本篇是純粹安裝zabbix4.0.1,  如果需要安裝lnmp請安裝 https://www.cnblogs.com/effortsing/p/9982028.html


環境準備:

一臺虛擬機器   192.168.1.204

關閉防火牆、selinux


1、首先安裝lnmp架構實現能訪問php、能連線mysql,mysql、php、nginx 都啟動


2、安裝zabbix

1)下載安裝包
[[email protected] ~]# cd /usr/local/

[[email protected] local]# wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.0.1/zabbix-4.0.1.tar.gz
2)安裝依賴包 [[email protected] local]# yum install libevent libevent-devel libaio gcc libxml* unixODBC-devel mysql-devel net-snmp-devel libxml2-devel libcurl-devel libevent-devel pcre* -y [[email protected] local]# yum -y install mysql-devel libcurl-devel net-snmp-devel php-bcmath php-ldap php-mbstring php-gd php-xmlwriter libevent-devel libevent pcre* 3
)新增使用者 [[email protected] local]# groupadd zabbix [[email protected] local]# useradd -g zabbix -s /sbin/nologin zabbix 4)建立資料庫並新增授權賬號 [[email protected] local]# mysql -u root [email protected]123 -e "create database zabbix character set utf8;" [[email protected] local]# 5)編譯安裝 [
[email protected]
local]# cd zabbix
-4.0.1 [[email protected] zabbix-4.0.1]# ./configure -prefix=/usr/local/zabbix -enable-server -enable-agent -with-mysql -with-net-snmp -with-libcurl [[email protected] zabbix-4.0.1]# make -j 4 && make install 6)匯入資料庫 [[email protected] zabbix-4.0.1]# mysql -uzabbix -p'[email protected]′ -hlocalhost zabbix < database/mysql/schema.sql [[email protected] zabbix-4.0.1]# mysql -uzabbix [email protected]123 -hlocalhost zabbix < database/mysql/images.sql [[email protected] zabbix-4.0.1]# mysql -uzabbix [email protected]123 -hlocalhost zabbix < database/mysql/data.sql 7) 修改zabbix配置檔案 [[email protected] zabbix-4.0.1]# sed -i 's/^DBUser=.*$/DBUser=zabbix/g' /usr/local/zabbix/etc/zabbix_server.conf [[email protected] zabbix-4.0.1]# sed -i 's/^.*DBPassword=.*$/[email protected]/g' /usr/local/zabbix/etc/zabbix_server.conf [[email protected] zabbix-4.0.1]# sed -i 's/^DBSocket=.*$/DBSocket=\/var\/lib\/mysql\/mysql.sock/g' /usr/local/zabbix/etc/zabbix_server.conf [[email protected] zabbix-4.0.1]# mkdir -p /var/www/html/zabbix [[email protected] zabbix-4.0.1]# cp -r frontends/php /var/www/html/zabbix [[email protected] zabbix-4.0.1]# cp misc/init.d/fedora/core/zabbix_* /etc/init.d/ [[email protected] zabbix-4.0.1]# sed -i 's/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix/g' /etc/init.d/zabbix_server [[email protected] zabbix-4.0.1]# sed -i 's/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix/g' /etc/init.d/zabbix_agentd 8)新增服務埠 cat >>/etc/services <<EOF 10050/tcp Zabbix Agent 10050/udp Zabbix Agent 10051/tcp Zabbix Trapper 10051/udp Zabbix Trapper 9)修改php.ini sed -i 's/^\(.*\)date.timezone =.*$/date.timezone = Asia\/Shanghai/g' /etc/php.ini sed -i 's/^\(.*\)post_max_size =.*$/post_max_size = 16M/g' /etc/php.ini sed -i 's/^\(.*\)max_execution_time =.*$/max_execution_time = 300/g' /etc/php.ini sed -i 's/^\(.*\)max_input_time =.*$/max_input_time = 300/g' /etc/php.ini sed -i 's/^\(.*\)always_populate_raw_post_data =.*$/always_populate_raw_post_data = .*/g' /etc/php.ini 10)配置nginx cat >> /etc/nginx/conf.d/default.conf << EOF server { listen 80 default_server; listen [::]:80 default_server; server_name 192.168.1.204; location / { root /var/www/html/zabbix/php; index index.php index.html; } location ~ \.php$ { root /var/www/html/zabbix/php; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/local/zabbix/php$fastcgi_script_name; include fastcgi_params; } } EOF 11) 修改許可權 [[email protected] zabbix-4.0.1]# cp -r /usr/local/php-7.1.1/ext/session/ /var/lib/php/ [[email protected] zabbix-4.0.1]# chown -R root:root /var/lib/php/ [[email protected] zabbix-4.0.1]# chmod 777 /var/lib/php/session/ 12) 重啟nginx、php、mysql [[email protected] zabbix-4.0.1]# systemctl stop mysqld && systemctl start mysqld;systemctl stop nginx && systemctl start nginx;/etc/init.d/php-fpm stop&& /etc/init.d/php-fpm sart 13)啟動zabbix /etc/init.d/zabbix_server start /etc/init.d/zabbix_agentd start echo "/etc/init.d/zabbix_server start" >> /etc/rc.local echo "/etc/init.d/zabbix_agentd start" >> /etc/rc.local 14)設定開機自啟 chkconfig --add zabbix_server chkconfig --add zabbix_agentd chkconfig zabbix_server on chkconfig zabbix_agentd on 15) 訪問zabbix http://192.168.1.204/setup.php


參照文件:

http://www.manongjc.com/article/18077.html 4.0.1 版本

http://www.safecdn.cn/2018/11/lnmp-zabbix4-0-1-install/