LNMP+Zabbix4.0编译安装

  • Post author:
  • Post category:Zabbix
  • Page Views 614 阅读

1.准备环境

事先准备好LNMP环境:>>> LNMP自动安装脚本 <<<

2.安装依赖

由于许多依赖LNMP已安装,现额外安装以下依赖:

[root@LNMP ~]# yum install -y net-snmp-devel unixODBC-devel libssh2-devel OpenIPMI-devel java-devel 

3.创建用户

[root@LNMP ~]# useradd zabbix -s /sbin/nologin -M

4.下载安装包

[root@LNMP ~]# wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.0.18/zabbix-4.0.18.tar.gz

5.编译安装

[root@LNMP zabbix-4.0.18]# ./configure \
--prefix=/usr/local/zabbix \
--exec-prefix=/usr/local/zabbix \
--bindir=/usr/local/zabbix/bin \
--sbindir=/usr/local/zabbix/sbin \
--sysconfdir=/usr/local/zabbix/etc \
--datadir=/usr/local/zabbix/share \
--includedir=/usr/local/zabbix/include \
--libdir=/usr/local/zabbix/lib \
--libexecdir=/usr/local/zabbix/libexec \
--localstatedir=/usr/local/zabbix/var \
--sharedstatedir=/usr/local/zabbix/var/com \
--mandir=/usr/local/zabbix/share/man \
--infodir=/usr/local/zabbix/share/info \
--enable-server \
--enable-agent \
--enable-proxy \
--enable-ipv6 \
--enable-java \
--with-net-snmp \
--with-ldap \
--with-libcurl \
--with-openipmi \
--with-unixodbc \
--with-ssh2 \
--with-libxml2 \
--with-libevent \
--with-libpcre \
--with-openssl \
--with-mysql=/usr/local/mysql/bin/mysql_config \
--with-iconv=/usr/local/libiconv
[root@LNMP zabbix-4.0.18]# make
[root@LNMP zabbix-4.0.18]# make install

6.创建数据库与用户

mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
mysql> flush privileges;

7.导入数据库文件

如果只安装Zabbix-proxy只需要导入schema.sql

[root@LNMP ~]# cd zabbix-4.0.18
[root@LNMP zabbix-4.0.18]# mysql -uzabbix -pzabbix zabbix < database/mysql/schema.sql
[root@LNMP zabbix-4.0.18]# mysql -uzabbix -pzabbix zabbix < database/mysql/images.sql
[root@LNMP zabbix-4.0.18]# mysql -uzabbix -pzabbix zabbix < database/mysql/data.sql

8.创建日志目录

[root@LNMP zabbix-4.0.18]# mkdir -p /usr/local/zabbix/log
[root@LNMP zabbix-4.0.18]# chown -R zabbix.zabbix /usr/local/zabbix/

9.复制启动脚本

[root@LNMP zabbix-4.0.18]# cp misc/init.d/fedora/core/zabbix_* /etc/init.d/
[root@LNMP zabbix-4.0.18]# chmod 755 /etc/init.d/zabbix_*
[root@LNMP zabbix-4.0.18]# sed -i "s#BASEDIR=/usr/local#BASEDIR=/usr/local/zabbix#g" /etc/init.d/zabbix_server
[root@LNMP zabbix-4.0.18]# sed -i "s#BASEDIR=/usr/local#BASEDIR=/usr/local/zabbix#g" /etc/init.d/zabbix_agentd

10.复制前端代码到站点目录

[root@LNMP zabbix-4.0.18]# cp -r frontends/php/* /web/www/zabbix/
[root@LNMP zabbix-4.0.18]# chown -R nginx.nginx /web/www/zabbix/

11.修改zabbix需要的php.ini参数

memory_limit = 128M
post_max_size = 16M
upload_max_filesize = 2M
max_execution_time = 300
max_input_time = 300
session.auto_start = 0

12.修改zabbix_server.conf

/usr/local/zabbix/etc

[root@LNMP etc]# egrep 'LogFile=|PidFile|DBHost|DBName|DBUser|DBPassword' zabbix_server.conf
LogFile=/usr/local/zabbix/log/zabbix_server.log
PidFile=/tmp/zabbix_server.pid
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix

12.启动服务

[root@LNMP etc]# chkconfig zabbix_server on
[root@LNMP etc]# chkconfig zabbix_agentd on
[root@LNMP etc]# service zabbix_server start
Starting zabbix_server (via systemctl): [ OK ]
[root@LNMP etc]# service zabbix_agentd start
Starting zabbix_agentd (via systemctl): [ OK ]

访问:http://IP


「 文章如果对你有帮助,请点个赞哦^^ 」 

0