首先安装LAMP环境
一、安装Apache
1、安装httpd。
yum install -y httpd
2、查看启动状态。
systemctl status httpd
3、启动httpd。
systemctl start httpd
4、添加开机启动。
systemctl enable httpd
5、设置防火墙开放tcp80端口。
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
firewall-cmd --query-port=80/tcp
8、创建文件/var/www/html/index.html,写入内容 “This is a test page.” 。
浏览器访问http://IP/index.html,显示This is a test page,说明安装的Apache HTTP服务正常运行。
二、安装mysql数据库
1、安装mariadb-server。
yum install -y mariadb-server
2、启动mariadb。
systemctl start mariadb.service
3、查看启动状态。
systemctl status mariadb
4、添加开机启动。
systemctl enable mariadb
5、设置mysql数据库root账号密码。
mysql_secure_installation
mysql安全步骤和原先一样,参考前面文章,不做详细说明
MariaDB[(none)]> quit;
6、设置防火墙开放tcp3306端口。
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload
firewall-cmd --query-port=3306/tcp
三、安装PHP
1、安装php。
yum install -y php
2、创建文件/var/www/html/index.php,写入内容 “<?php phpinfo(); ?>”。
vim /var/www/html/index.php
3、重启apache服务,浏览器访问http://192.168.1.200/index.php,如果显示PHP版本页面,则说明php安装成功。
systemctl restart httpd
四、安装Zabbix
- 安装 数据库
rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/8/x86_64/zabbix-release-4.4-1.el8.noarch.rpm
dnf clean all
- 安装Zabbix server,Web前端,agent
dnf -y install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-agent
- 创建初始数据库
mysql -uroot -p
password
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'password';
mysql> quit;
4.导入初始架构和数据,系统将提示您输入新创建的密码。
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
- 为Zabbix server配置数据库
vim /etc/zabbix/zabbix_server.conf
DBPassword=password
- 为Zabbix前端配置PHP
vim /etc/php-fpm.d/zabbix.conf
php_value[date.timezone] = Asia/Shanghai
- 启动Zabbix server和agent进程
systemctl restart zabbix-server zabbix-agent httpd php-fpm
systemctl enable zabbix-server zabbix-agent httpd php-fpm
启动遇到问题如下:
Job for zabbix-server.service failed because the control process exited with error code.
See "systemctl status zabbix-server.service" and "journalctl -xe" for details.
检查日志:
journalctl -xe
运行以下命令排错
ausearch -c 'zabbix_server' --raw | audit2allow -M my-zabbixserver
semodule -X 300 -i my-zabbixserver.pp
五. 配置Zabbix前端
http://server_ip_or_name/zabbix
配置步骤和原先一样,不做赘述。