yum install nginx php php-devel php-mysql php-fpm mariadb mariadb-server mariadb-devel epel-release -y
systemctl start mariadb
create database zabbix charset=utf8;
grant all to zabbix.* to zabbix@localhost identified by '123456'
flush privileges;
[root@localhost ~]# cd zabbix-3.4.8/
[root@localhost zabbix-3.4.8]# pwd
/root/zabbix-3.4.8
[root@localhost zabbix-3.4.8]# mysql -uzabbix -p123456 zabbix <database/mysql/schema.sql
[root@localhost zabbix-3.4.8]# mysql -uzabbix -p123456 zabbix <database/mysql/images.sql
[root@localhost zabbix-3.4.8]# mysql -uzabbix -p123456 zabbix <database/mysql/mysql.sql
[root@localhost zabbix-3.4.8]# mysql -uzabbix -p123456 zabbix <database/mysql/data.sql
#schema.sql 表结构
#images.sql 图片库
#data.sql 初始脚本库
#三个表导入次序不能颠倒:schema-->images-->data。
[root@localhost ~]# tar -zxf zabbix-3.4.8.tar.gz
[root@localhost ~]# cd zabbix-3.4.8/
[root@localhost zabbix-3.4.8]#
[root@localhost zabbix-3.4.8]# yum gcc gcc-c++ open openssl-devel zlib zlib-devel pcre pcre-devel net-snmp net-snmp-devel curl curl-devel libevent-devel -y
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --enable-ipv6 --with-mysql --with-net-snmp --with-libcurl
make && make install
写到这里zabbix-web、zabbix-server安装部分完成,同时zabbix-mariadb安装和配置也完成。下面进zabbix配置文件环节
[root@localhost ~]# cp /usr/local/zabbix/etc/zabbix.server.conf /usr/local/zabbix/etc/zabbix.server.conf.bak
[root@localhost ~]# cat >/usr/local/zabbix/etc/zabbix.server.conf <<EOF
LogFile=/tmp/zabbix_server.log
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123456
EOF
[root@localhost ~]# cd zabbix-3.4.8/
[root@localhost zabbix-3.4.8]# cp -a misc/init.d/tru64/zabbix_* /etc/init.d/
[root@localhost zabbix-3.4.8]# chmod +x /etc/init.d/zabbix_*
**运行报错 1**
[root@localhost ~]# /etc/init.d/zabbix_server start
Can't find file /usr/local/sbin/zabbix_server.
Zabbix server NOT started.
#运行zabbix启动程序报错:提示链接zabbix启动二进制错误,修改/etc/init.d/zabbix_server脚本来解决。
[root@localhost ~]# vim /etc/init.d/zabbix_server
#找到第24行修改为/usr/local/zabbix/sbin/zabbix_server
![](https://img2018.cnblogs.com/blog/1846345/201910/1846345-20191028011411958-575921307.png)
**运行报错 2**
[root@localhost ~]# /etc/init.d/zabbix_server start
zabbix_server [32842]: user zabbix does not exist
zabbix_server [32842]: cannot run as root!
Zabbix server started.
#错误提示:zabbix用户不存在,开启zabbix失败。解决:添加用户zabbix后,在启动zabbix启动程序就OK。
[root@localhost ~]# useradd zabbix
[root@localhost ~]# /etc/init.d/zabbix_server start
Zabbix server started.
12. php和nginx整合配置,修改nginx配置文件
location / {
index index.php setup.php;
}
location ~ .php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
13. 重新启动nginx和php服务
[root@localhost nginx]# systemctl restart nginx php-fpm
14. 访问zabbix web页面
![](https://img2018.cnblogs.com/blog/1846345/201910/1846345-20191028011349300-1495063186.png)
## 待续
原文:https://www.cnblogs.com/linux123/p/11750111.html