zabbix+nginx+php7.0+debian9的部署方法

RT 官方建议apache2,然而并不想用apache2
数据库保持使用MySql,量小暂时没有PostgreSQL的需求
依旧是root账号,所以不带sudo

1、安装基础
这里比较偷懒就直接apt装nginx了,有版本需求自行编译,apt装好的nginx config在/etc/nginx下面,请注意

apt-get update
apt-get install nginx php7.0-fpm php7.0-mysql mysql-server

装完先放着

2、安装zabbix-server和anget(可选)

wget http://repo.zabbix.com/zabbix/3.4/debian/pool/main/z/zabbix-release/zabbix-release_3.4-1%2Bstretch_all.deb
dpkg -i zabbix-release_3.4-1+stretch_all.deb
apt-get update
apt-get install zabbix-server-mysql zabbix-frontend-php zabbix-agent

安装完后可能会把apache2也给你装上了,删了删了

systemctl stop apache2.service
apt-get remove apache2
apt autoremove

然后继续放着

3、配置数据库

mysql -uroot -p
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by '***YOURPASSWORD***';
quit;
cd /usr/share/doc/zabbix-server-mysql
zcat create.sql.gz | mysql -uzabbix -p zabbix

配置zabbix-server用的数据库,然后导入初始架构数据
mysql的root的密码默认跟随系统的root密码,而不再是安装的时候另外设置了

4、配置nginx和php-fpm

vim /etc/nginx/sites-enabled/zabbix.conf

server {
       listen 80;
        server_name  localhost;
        root   /usr/share/zabbix;


        location / {
                index  index.html index.htm index.php;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
                root   /usr/share/nginx/html;
        }
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php7.0-fpm.sock;
                include        fastcgi_params;
        }
}

php-fpm在apt安装的情况下默认就用的sock,所以不用改动,如果是其他安装方法的话请自行检查和修改

vim /etc/php/7.0/fpm/php.ini

max_execution_time = 300
max_input_time = 600
post_max_size = 32M
date.timezone = Asia/Tokyo

以上4条请用搜索功能寻找并修改

5、配置zabbix-server和agent

vim /etc/zabbix/zabbix_server.conf

DBHost=
DBName=
DBPassword=

以上3条请自行搜索并修改

vim /etc/zabbix/zabbix_agentd.conf

Server=
Hostname=

以上2条请自行搜索并修改

6、开机自动启动和启动服务并访问

systemctl enable nginx
systemctl enable php7.0-fpm
systemctl enable mysql
systemctl enable zabbix-server
systemctl enable zabbix-agent
systemctl restart nginx
systemctl restart php7.0-fpm
systemctl restart mysql
systemctl restart zabbix-server
systemctl restart zabbix-agent

写的比较糙,有些可能是需要restart

然后打开浏览器,http://yourdomain/setup.php 进入zabbix的配置页面,剩下的跟着流程走一遍即可~

PS:初始账号密码是 Admin和zabbix(账号注意大小写)

参考资料:
从部署包安装 Zabbix Documentation 3.4
ubuntu16.04 + ZABBIX + nginx & php-fpm