一.LAMP 安装环境
1.1安装Apche
[root@localhost ~]#yum install -y httpd
[root@localhost ~]#systemctl start httpd
[root@localhost ~]#systemctl enable httpd
1.2安装mariadb
[root@localhost ~]# yum install -y mariadb mariadb-server
[root@localhost ~]# systemctl enable mariadb.service
[root@localhost ~]# systemctl start mariadb.service
1.3安装php
## 首先说明,centos8其实是自带php7.2的,只不过是没启用,所以我们来看以下步骤:
[root@localhost ~]# dnf module list php
Last metadata expiration check: 0:14:17 ago on Fri 12 Mar 2021 03:28:39 PM CST.
CentOS-8 - AppStream
Name Stream Profiles Summary
php 7.2 [d][e] common [d], devel, mi PHP scripting lang
nimal uage
php 7.3 common [d], devel, mi PHP scripting lang
nimal uage
php 7.4 common [d], devel, mi PHP scripting lang
nimal uage
Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
## 启用php7.2
首先重置
dnf module reset php
然后启用php7.2
dnf module enable php:7.2
安装php插件
dnf install -y php php-opcache php-gd php-curl php-mysqlnd
查看php版本
php -v
继续安装插件,以运行web
dnf install -y php-bcmath php-mbstring php-xmlwriter php-xmlreader php-cli php-ldap php-zip php-fileinfo
接下来就可以重启service
systemctl restart httpd.service
systemctl restart php-fpm
二.Zabbix监控Zabbix 4.4
安装zabbix
a.安装Zabbix库
[root@localhost ~]# rpm -Uvh https://repo.zabbix.com/zabbix/5.2/rhel/8/x86_64/zabbix-release-5.2-1.el8.noarch.rpm
[root@localhost ~]# dnf clean all
b.安装zabbix 组件:安装Zabbix server,Web前端,agent
[root@localhost ~]#dnf install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-agent
c.创建初始数据库,在数据库主机上运行以下代码。
# mysql -uroot -p
password
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> create user zabbix@localhost identified by 'password'; // (这里我设的是zabbix)
mysql> grant all privileges on zabbix.* to zabbix@localhost;
mysql> quit;
# 导入初始架构和数据,输入刚才新创建的密码zabbix。
[root@localhost ~]#zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -pzabbix;
d. 为Zabbix server配置数据库
编辑配置文件 /etc/zabbix/zabbix_server.conf
DBPassword=password //(这里我设的为zabbix)
e. 启动Zabbix server和agent进程
启动Zabbix server和agent进程,并为它们设置开机自启:
systemctl restart zabbix-server zabbix-agent httpd php-fpm
systemctl enable zabbix-server zabbix-agent httpd php-fpm
# 如果这里重启服务没有反应,可以单独启动
zabbix日志路径
/var/log/zabbix/zabbix_server.log
zabbix修改语言为中文
a.安装语言包
yum install glibc-langpack-zh.x86_64
b.查看是否安装成功
[root@localhost ~]# localectl list-locales | grep zh
zh_CN
zh_CN.gb18030
zh_CN.gbk
zh_CN.utf8
zh_HK
zh_HK.utf8
zh_SG
zh_SG.gbk
zh_SG.utf8
zh_TW
zh_TW.euctw
zh_TW.utf8
c.切换默认语言包
# 此步按需执行,本人安装语言包是为了zabbix设置成中文界面,所以这步不执行
localectl set-locale LANG=zh_CN.utf8
d.修改完成后更新
修改客户端agent(这里同样也监控本机,所以是本机设置)
vim /etc/zabbix/zabbix_agentd.conf
Server=localhost //服务端的ip
Hostname=Zabbix Server //与zabbix创建的主机名一致