lnmp和lamp架构搭建略
1、下载对应的版本(以下安装是以Zabbix 3.2版本为例)
https://www.zabbix.com/download
2、解压软件包
root@zabbix:~/tools# apt-get -y install net-snmp net-snmp-devel curl curl-devel libxml2 libxml2-devel #安装zabbix依赖包
root@zabbix:~/tools# tar xf zabbix-3.2.10.tar.gz
root@zabbix:~/tools/zabbix-3.2.10# ./configure --prefix=/usr/local/zabbix --enable-server --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --enable-agent --enable-ipv6
root@zabbix:~/tools/zabbix-3.2.10# make && make install
3、创建zabbix虚拟账户
root@zabbix:~# useradd -s /sbin/nologin -M zabbix
4、MySQL数据库修改
mysql> create database zabbix; #创建zabbix数据库
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by ‘zabbix‘; #添加zabbix账户并授权到zabbix数据库
mysql> flush privileges; #添加完后一定要执行此命令
5、进入zabbix解压目录,导入zabbix数据库表文件
root@zabbix:~/tools/zabbix-3.2.10# mysql -uzabbix -pzabbix zabbix < database/mysql/schema.sql
root@zabbix:~/tools/zabbix-3.2.10# mysql -uzabbix -pzabbix zabbix < database/mysql/images.sql
root@zabbix:~/tools/zabbix-3.2.10# mysql -uzabbix -pzabbix zabbix < database/mysql/data.sql
6、进入zabbix安装目录修改zabbix配置文件
root@zabbix:/usr/local/zabbix/etc# vim zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zbpass
AlertScriptsPath=/usr/local/etc/zabbix/alertscripts
7、修改zabbix_agentd.conf配置文件
root@zabbix:/usr/local/zabbix/etc# vim zabbix_agentd.conf
LogFile=/var/log/zabbix/zabbix_agentd.log
Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=Zabbix server
8、修改php.ini文件(/etc/php.ini)
sed -i ‘s/post_max_size = 8M/post_max_size = 32M/g‘ /etc/php.ini
sed -i ‘s/upload_max_filesize = 2M/upload_max_filesize = 50M/g‘ /etc/php.ini
sed -i ‘s/;date.timezone =/date.timezone =PRC/‘ /etc/php.ini
sed -i ‘s/max_execution_time = 30/max_execution_time = 600/g‘ /etc/php.ini
sed -i ‘s/max_input_time = 60/max_input_time = 600/g‘ /etc/php.ini
sed -i ‘s/memory_limit = 128M/memory_limit = 256M/g‘ /etc/php.ini
9、拷贝zabbix服务端、客户端启动脚本到/etc/init.d目录下
root@zabbix:~/tools/zabbix-3.2.10/misc/init.d/debian# cp zabbix_server /etc/init.d/
root@zabbix:~/tools/zabbix-3.2.10/misc/init.d/debian# zabbix_agentd /etc/init.d/
root@zabbix:~# chmod +x /etc/init.d/zabbix_*
10、在apache/nginx主目录下创建zabbix文件夹,再找到zabbix php文件下的所有文件复制到apache/nginx网页家目录下
root@zabbix:~/tools/zabbix-3.2.10/frontends/php# cp -rf * /var/html/www/zabbix
11、启动zabbix服务(注意编译安装的如指定了目录需要把命令路径加到系统环境变量中)
root@zabbix:~# /etc/init.d/zabbix_server start
root@zabbix:~# /etc/init.d/zabbix_agentd start
12、重启apache/nginx服务
/etc/init.d/apache2 restart
13、通过http://IP/zabbix 进行图形化安装zabbix