LAMP与zabbix4.0 环境部署
LAMP与zabbix4.0 环境部署
环境
关闭防火墙,Selinux
systemctl stop firewalld
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0
LAMP环境部署
yum -y install http mariadb mariadb-server mariadb-devel php-fpm php
vim /var/www/html/index.php
<?php
phpinfo();
?>
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
systemctl restart httpd php-fpm mariadb
systemctl enable httpd php-fpm mariadb
mysql_secure_installation # 初始化mariadb
mysql -uroot -p # 能够正常登录
reboot
http://192.168.50.66/index.php # 测试是否能够正常解析php
补充:
apache的web目录在:/var/www/html
安装zabbix4.0.
cat <<EOF > /etc/yum.repos.d/zabbix.repo
[zabbix]
name=Zabbix Official Repository - \$basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/\$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - \$basearch
baseurl=https://mirrors.aliyun.com/zabbix/non-supported/rhel/7/\$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1
EOF
curl https://mirrors.aliyun.com/zabbix/RPM-GPG-KEY-ZABBIX-A14FE591 -o /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
curl https://mirrors.aliyun.com/zabbix/RPM-GPG-KEY-ZABBIX -o /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
# rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm 下载速度太慢,所以使用上面的aliyun镜像地址
yum clean all
yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent
## 如果出现下面的情况
## failed to link /usr/share/zabbix/fonts/graphfont.ttf -> /etc/alternatives/zabbix-web-font: No such file or directory
## 进行解决
## 在windows里面找一个显示中文的字体文件复制到服务器中
mkdir /usr/share/zabbix/fonts
mv SIMHEI.TTF /usr/share/zabbix/fonts/graphfont.ttf
ln -s /usr/share/zabbix/fonts/graphfont.ttf /etc/alternatives/zabbix-web-font
创建,配置zabbix
1.创建zabbix库,并授权用户
mysql -uroot -p123456
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@'%' identified by '123456';
msyql> flush privileges
2.解压zabbix数据库文件并导入数据库
gunzip /usr/share/doc/zabbix-server-mysql*/create.sql.gz
# 方法1:
mysql -uroot -p zabbix < /usr/share/doc/zabbix-server-mysql*/create.sql
# 方法2:
mysql -uroot -p123456
mysql> use zabbix;
mysql> source create.sql;
mysql> show tables;
# 方法3:
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
# 移动文件到web根目录
cp -rp /usr/share/zabbix /var/www/html/
启动各项服务
systemctl restart zabbix-server zabbix-agent httpd php-fpm mariadb
systemctl enbale zabbix-server zabbix-agent httpd php-fpm mariadb
访问网页,从网页进行安装
出现上图,按照要求进行设置相关配置文件
主要的配置文件有:
/etc/php.ini
/etc/httpd/conf.d/zabbix.conf
当全部为绿色后就可以进行下一步
登录的时候,默认账户名Admin
,密码zabbix
注意: 图片可能是其他版本的,但不影响操作
参考文献:zabbix安装官方参考
参考文献:zabbix图像配置参考
解决Zabbix server is not running :the information displayed may not be current.
在登录了zabbix首页之后,可能在底部会出现
Zabbix server is not running :the information displayed may not be current.
可能出现的原因:
- 防火墙阻止了nginx服务
- 数据库授权有问题
- zabbix的web配置文件配置问题
- dns的解析问题
1.防火墙
# 关闭防火墙和selinux
systemctl status firewalld
systemctl stop firewalld
systemctl disabled firewalld
# 关闭selinux
setenforce 0 # 临时关闭
sed -i '/^SELINUX=/cSELINUX=disabled' /etc/selinux/config
2.更改zabbix的web配置文件
配置文件名:zabbix.conf.php
可以通过find / -name "zabbix.conf.php"
查找,之后按照下图进行修改
3.数据库授权
一般问题不会在这,因为安装之前已经授权了,但由于刚才修改了web文件,需要重新授权
mysql -uroot -p123456
mysql> grant all privileges on zabbix.* to zabbix@'%' identified by 123456;
mysql> flush privileges;
mysql> exit
4.检查dns,并修改
1.修改DNS
vim /etc/hosts
2.重启nginx
systemctl restart nginx
5.检查配置文件
vim /etc/zabbix/zabbix_server.conf
DBHost=192.168.50.66
DBName=zabbix
DBUser=zabbix
DBPassword=123456
6.重启服务
systemctl restart zabbix-agent.service zabbix-server.service httpd php-fpm.service mariadb
7.登录web界面
http://192.168.50.66/zabbix
本文来自博客园,作者:Lin-Grocery,转载请注明原文链接:https://www.cnblogs.com/moniter/articles/12305159.html