两台虚拟机搭建zabbix监控(lnmp)

1. lnmp搭建

安装环境:
mysql php zabbix:192.168.110.21
nginx:192.168.110.20

1.1 mysql安装

详情请看mysql安装

1.2 php安装

详情请看php安装

1.3 nginx安装

详情请看nginx安装

1.4 zabbix安装

详情请看zabbix安装

2. 配置

2.1关闭防火墙

[root@lw ~]# systemctl stop firewalld
[root@lw ~]# setenforce 0
setenforce: SELinux is disabled

[root@liuwei ~]# systemctl stop firewalld
[root@liuwei ~]# setenforce 0
setenforce: SELinux is disabled

2.2修改php配置文件

[root@lw ~]# vim /usr/local/php7/etc/php-fpm.d/www.conf
listen = 192.168.110.21:9000   //监听本机ip
listen.allowed_clients = 192.168.110.20    //允许连接php服务的ip

2.3 zabbix web界面安装配置

[root@lw ~]# cd zabbix-4.0.3
[root@lw zabbix-4.0.3]# cp -a /usr/local/apache/htdocs/zabbix/ /usr/local/nginx/html/
[root@lw html]# chmod -R 777 zabbix
[root@lw html]# chown -R nginx.nginx zabbix

2.4 修改nginx的配置文件

[root@liuwei ~]# vim /usr/local/nginx/conf/nginx.conf
        location / {
            root   html;
            index  index.php index.html index.htm ;    ##注:添加index.php
        }
        
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            root           /usr/local/nginx/html/zabbix;    ##注:网页文件存放目录,在php端的/usr/local/nginx/html/目录下
            fastcgi_pass   192.168.110.21:9000;  ##注:修改为php服务器地址
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;     ##注:将$/scripts修改为根目录(192.168.110.21服务器的存放网页文件的目录)
            include        fastcgi_params;
        }

2.5 安装并设置nfs共享

//必须设置nfs,要不然会没有图像界面

[root@lw ~]# yum -y install nfs-utils
[root@lw ~]# systemctl start nfs
[root@lw ~]# vim /etc/exports
/usr/local/apache/htdocs/zabbix *(rw)

[root@liuwei ~]# yum -y install nfs-utils
[root@liuwei ~]# systemctl start nfs
[root@liuwei ~]# mount -t nfs 192.168.110.21:/usr/local/apache/htdocs/zabbix/ /usr/local/nginx/html/
[root@liuwei ~]# mount -t nfs 192.168.110.21:/usr/local/apache/htdocs/zabbix/ /usr/local/nginx/html/
[root@liuwei ~]# df -Th
文件系统                                       类型      容量  已用  可用 已用% 挂载点
/dev/mapper/rhel-root                          xfs        18G  2.9G   15G   17% /
devtmpfs                                       devtmpfs  901M     0  901M    0% /dev
tmpfs                                          tmpfs     912M     0  912M    0% /dev/shm
tmpfs                                          tmpfs     912M  8.6M  904M    1% /run
tmpfs                                          tmpfs     912M     0  912M    0% /sys/fs/cgroup
/dev/sda1                                      xfs       497M  136M  362M   28% /boot
tmpfs                                          tmpfs     183M     0  183M    0% /run/user/0
192.168.110.21:/usr/local/apache/htdocs/zabbix nfs4       17G  6.3G   11G   37% /usr/local/nginx/html
[root@liuwei ~]# systemctl restart nfs
[root@liuwei ~]# vim /etc/fstab 
192.168.110.21:/usr/local/apache/htdocs/zabbix /usr/local/nginx/html nfs defaults 0 0

2.6 两边重启服务

[root@lw html]# service php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm  done

[root@liuwei ~]# nginx -s reload

3. 验证

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值