源码安装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)下载安装包 [root@www ~]# cd /usr/local/ [root@www local]# wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.0.1/zabbix-4.0.1.tar.gz 2)安装依赖包 [root@www local]# yum install libevent libevent-devel libaio gcc libxml* unixODBC-devel mysql-devel net-snmp-devel libxml2-devel libcurl-devel libevent-devel pcre* -y [root@www 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)添加用户 [root@www local]# groupadd zabbix [root@www local]# useradd -g zabbix -s /sbin/nologin zabbix 4)创建数据库并添加授权账号 [root@www local]# mysql -u root -pjenkins@123 -e "create database zabbix character set utf8;" [root@www local]# mysql -u root -pjenkins@123 -e "grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix@123';"
5)编译安装 [root@www local]# cd zabbix-4.0.1 [root@www zabbix-4.0.1]# ./configure -prefix=/usr/local/zabbix -enable-server -enable-agent -with-mysql -with-net-snmp -with-libcurl [root@www zabbix-4.0.1]# make -j 4 && make install 6)导入数据库 [root@www zabbix-4.0.1]# mysql -uzabbix -p'zabbix@123′ -hlocalhost zabbix < database/mysql/schema.sql [root@www zabbix-4.0.1]# mysql -uzabbix -pzabbix@123 -hlocalhost zabbix < database/mysql/images.sql [root@www zabbix-4.0.1]# mysql -uzabbix -pzabbix@123 -hlocalhost zabbix < database/mysql/data.sql 7) 修改zabbix配置文件 [root@www zabbix-4.0.1]# sed -i 's/^DBUser=.*$/DBUser=zabbix/g' /usr/local/zabbix/etc/zabbix_server.conf [root@www zabbix-4.0.1]# sed -i 's/^.*DBPassword=.*$/DBPassword=zabbix@123/g' /usr/local/zabbix/etc/zabbix_server.conf [root@www zabbix-4.0.1]# sed -i 's/^DBSocket=.*$/DBSocket=\/var\/lib\/mysql\/mysql.sock/g' /usr/local/zabbix/etc/zabbix_server.conf [root@www zabbix-4.0.1]# mkdir -p /var/www/html/zabbix [root@www zabbix-4.0.1]# cp -r frontends/php /var/www/html/zabbix [root@www zabbix-4.0.1]# cp misc/init.d/fedora/core/zabbix_* /etc/init.d/ [root@www zabbix-4.0.1]# sed -i 's/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix/g' /etc/init.d/zabbix_server [root@www 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 EOF 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) 修改权限 [root@www zabbix-4.0.1]# cp -r /usr/local/php-7.1.1/ext/session/ /var/lib/php/ [root@www zabbix-4.0.1]# chown -R root:root /var/lib/php/ [root@www zabbix-4.0.1]# chmod 777 /var/lib/php/session/ 12) 重启nginx、php、mysql [root@www 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)设置开机自启
添加开启自启配置文件
cat >> /lib/systemd/system/nginx.service << EOF
#!/bin/bash
[Unit]
Description=zabbix
After=network.target
[Service]
Type=forking
ExecStart=/etc/init.d/zabbix_server start
ExecStop=/etc/init.d/zabbix_server stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
设置开机自启
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
下面让输入的密码是上面 2.4 步骤 创建数据库授权zabbix用户的密码
下面出现Fail的原因是zabbix的配置文件没有,需要点击“Download configuration file”将zabbix.conf.php下载到本地再通过rz上传到服务器的/usr/local/zabbix/php/conf目录下即可,然后点击Finish
到此web页面配置完毕,直接访问IP就可以登录,zabbix的默认登陆账号是admin,密码是zabbix
更换中文字体,登陆后在页面的右上角的“小人头” ,然后选择中文 ,最后点击Update
参照文档:
http://www.manongjc.com/article/18077.html
http://www.safecdn.cn/2018/11/lnmp-zabbix4-0-1-install/