LNMP环境下安装zabbix4.2.1

实操记录

1.本文以阿里云ECS CentOS 7.6 为例
2.lnmp环境安装采用OneinStack的一键安装包

检查一下SeLinux防火墙是否关闭,没的话关掉它

1.安装lnmp环境

root@cohesions.cn:~# wget -c http://mirrors.linuxeye.com/oneinstack-full.tar.gz && tar xzf oneinstack-full.tar.gz && ./oneinstack/install.sh --nginx_option 1 --php_option 7 --phpcache_option 1 --php_extensions imagick,fileinfo,imap,ldap --db_option 2 --dbinstallmethod 1 --dbrootpwd jockie --iptables  --ssh_port 22 --reboot 

注意:--dbrootpwd后面的为数据库密码,将 jockie 替换成你的密码

回车后你就可以先去干点别的了,这个时间有点长。。。

####################Congratulations########################
Total OneinStack Install Time: 35 minutes

Nginx install dir:              /usr/local/nginx

Database install dir:           /usr/local/mysql
Database data dir:              /data/mysql
Database user:                  root
Database password:              jockie

PHP install dir:                /usr/local/php
Opcache Control Panel URL:      http://xxx.xxx.xxx.xxx/ocp.php

Index URL:                      http://xxx.xxx.xxx.xxx/
root@cohesions.cn:~#

到这里,lnmp环境就安装成功了。

顺便说一下这里lnmp对应的版本为NGINX1.16+MySQL5.7+PHP7.2


2.安装zabbix4.2.1

2.1创建用户组zabbix和创建用户zabbx

root@cohesions.cn:~# groupadd zabbix -g 201
root@cohesions.cn:~# useradd -M -r -g zabbix -u 201 -s /bin/false zabbix

在root下运行zabbix,zabbix会主动使用zabbix用户来运行,如果系统没有zabbix用户,需要创建

2.2下载Zabbix4.2.1源码包并解压

root@cohesions.cn:~# cd /usr/local/src
root@cohesions.cn:~# wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.2.1/zabbix-4.2.1.tar.gz  
root@cohesions.cn:~# tar xf zabbix-4.2.1.tar.gz 

2.3创建并导入数据库

root@cohesions.cn:/usr/local/src# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.26-log MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.03 sec)
MySQL [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
Query OK, 0 rows affected, 2 warnings (0.00 sec)
MySQL [(none)]> \q
Bye
root@cohesions.cn:/usr/local/src#cd /usr/local/src/zabbix-*/database/mysql/
root@cohesions.cn:/usr/local/src/zabbix-4.2.1/database/mysql# mysql -uzabbix -pzabbix zabbix < schema.sql   
root@cohesions.cn:/usr/local/src/zabbix-4.2.1/database/mysql# mysql -uzabbix -pzabbix zabbix < images.sql  
root@cohesions.cn:/usr/local/src/zabbix-4.2.1/database/mysql# mysql -uzabbix -pzabbix zabbix < data.sql  
root@cohesions.cn:/usr/local/src/zabbix-4.2.1/database/mysql#

导入数据库的顺序一定不能调换

2.4安装依赖

yum -y install net-snmp-devel libssh2 libssh2-devel curl-devel

在安装的过程可能还会出现其他错误,根据提示安装依赖

2.5编译安装zabbix4.2.1 server

root@cohesions.cn:~# cd /usr/local/src/zabbix-4.2.1
root@cohesions.cn:/usr/local/src/zabbix-4.2.1# ./configure --prefix=/usr/local --sysconfdir=/etc/zabbix --enable-server --with-ssh2 --with-openssl --with-mysql=/usr/local/mysql/bin/mysql_config --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2  
root@cohesions.cn:/usr/local/src/zabbix-4.2.1# make install

编译过程有点长

2.6修改zabbix_server.conf

因为编译安装默认日志在/tmp/下,个人习惯在/var/log/下

mkdir /var/log/zabbix   
chown -R zabbix.zabbix /var/log/zabbix/
sed -i s#"LogFile=/tmp/zabbix_server.log"#"LogFile=/var/log/zabbix/zabbix_server.log"# /etc/zabbix/zabbix_server.conf

修改DBPassword

sed -i s/"# DBPassword="/DBPassword=zabbix/ /etc/zabbix/zabbix_server.conf

2.7设置zabbix启动脚本

cp /usr/local/src/zabbix-*/misc/init.d/fedora/core5/zabbix_server /etc/init.d/
chkconfig --add /etc/init.d/zabbix_server
chkconfig zabbix_server on

2.8启动zabbix

/etc/init.d/zabbix_server start

到这里server端就安装好了


3配置Web端

3.1修改/etc/php.ini

sed -i s/";always_populate_raw_post_data = -1"/"always_populate_raw_post_data = -1"/ /usr/local/php/etc/php.ini
sed -i s/"max_input_time = 60"/"max_input_time = 300"/ /usr/local/php/etc/php.ini
/etc/init.d/php-fpm restart

3.2拷贝Web端

mkdir -p /data/wwwroot/zabbix
cp -a /usr/local/src/zabbix-*/frontends/php/* /data/wwwroot/zabbix/

3.3 登入http://ip/zabbix 进行最后的设置

zabbix默认账号:Admin 密码:zabbix

Last modification:June 3rd, 2019 at 07:23 pm
如果觉得我的文章对你有帮助,可以请我喝咖啡

Leave a Comment

,