文章目录
一:配置yum源
1:备份现有的yum源(更改名称就行)
2:创建阿里云yum源
wget -O /etc/yum.repos.d/aliyun.repo http://mirrors.aliyun.com/repo/Centos-7.repo
3:清理并重新加载yum源
yum clean all && yum makecache
二:关闭防火墙和selinux
systemctl disable --now firewalld
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
三:安装php
1:安装PHP
#centos7
yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum -y install yum-utils
yum -y install php php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json php-redis
yum-config-manager --enable remi-php74
yum list php
yum -y install php
#查看版本
php -v
#查看启动模块
php --modules
#查看安装路径
whereis php
2:启动,自启,查看运行状态
service php-fpm start
service php-fpm enable
service php-fpm status
四:安装apache
1:安装httpd
yum install httpd -y
systemctl restart httpd
systemctl enable httpd
#配置文件位置
/etc/httpd/conf/httpd.conf
/var/www/html
2:配置Apache解析PHP
vim /etc/httpd/conf.d/php-fpm.conf
<FilesMatch \.php$>
SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>
#Apache网页目录下编写简单的php网页,验证访问Apache的php网页
vim /var/www/html/index.php
<?php
phpinfo();
?>
#浏览器访问,会看到以下界面
http://IP/index.php
五:安装mysql
1:下载8.0+版本的mysql的yum存储库
wget https://repo.mysql.com//mysql84-community-release-el7-1.noarch.rpm
2:安装存储库
rpm -Uvh mysql84-community-release-el7-1.noarch.rpm
3:禁用系统自带的mysql模块(可选)
yum module disable mysql
4:安装mysql sever
yum install mysql-community-server
5:启动mysql服务
service mysqld start
6:查看服务状态
service mysqld status
7:查看初始密码
grep ‘temporary password’ /var/log/mysqld.log
8:登陆MySQL输入上面的密码
mysql -u root -p
9:修改密码
修改本地root用户登录密码
alter user 'root'@'localhost' identified by "P@ssw0rd";
创建全域root用户(允许root用户从其它地址访问)
create user 'root'@'%' identified by 'P@ssw0rd';
进行授权
grant all privileges on *.* to 'root'@'%';
flush privileges;
update mysql.user set Grant_priv='Y', Super_priv='Y' where user ='root' and host='%';
flush privileges;
quit
10:创建初始数据库
mysql -uroot -p
输入密码
mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
mysql> create user zabbix@localhost identified by 'P@ssw0rd';
mysql> grant all privileges on zabbix.* to zabbix@localhost;
mysql> set global log_bin_trust_function_creators = 1;
mysql> quit;
六:编译安装zabbix6.0
1:安装依赖
#安装依赖
yum install gcc -y
yum install openssl -y
yum install openssl-devel -y
yum -y install libxml2 libxml2-devel curl curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel zlib zlib-devel openldap openldap-devel sqlite-devel oniguruma-devel
yum install -y libevent-devel net-snmp-devel
yum install mysql-devel
2:下载zabbix6.0压缩包
#下载压缩包,解压
wget https://cdn.zabbix.com/zabbix/sources/stable/6.0/zabbix-6.0.0.tar.gz
tar -zvxf zabbix-6.0.0.tar.gz
3:创建用户组
#创建用户组等,授权
groupadd --system zabbix
useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix
mkdir -m u=rwx,g=rwx,o= -p /usr/lib/zabbix
chown zabbix:zabbix /usr/lib/zabbix
cd zabbix-6.0.0
#同步时钟,设置系统时间与网络时间同步
yum -y install ntpdate
4:编译安装
./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
make install
5:导入数据库
cd zabbix-6.0.0/database/mysql/
mysql -uzabbix -p zabbix < schema.sql
mysql -uzabbix -p zabbix < images.sql
mysql -uzabbix -p zabbix < data.sql
6:添加数据库zabbix用户的登陆密码
vi +/DBPassword /usr/local/etc/zabbix_server.conf
DBPassword= P@ssw0rd
DBSocket=/var/lib/mysql/mysql.sock
七:php修改参数
yum install php-bcmatch -y
find / -name php.ini
vim /etc/php.ini
max_execution_time = 300
max_input_time = 300
post_max_size = 16M
date.timezone = Asia/Shanghai
#启动server与agentd服务,在zabbix-6.0.0目录下
zabbix_server
zabbix_agentd
#Zabbix 前端是 PHP 编写的,所以必须运行在支持 PHP 的 Web 服务器上。需要从ui路径下复制 PHP 文件到 Web 服务器的 HTML 文档目录,完成安装,把整个ui目录都拷贝过去并命名为zabbix,在zabbix-6.0.0目录下
cp -r ui /var/www/html/zabbix/
#为了使参数生效,重启php-fpm,httpd服务
systemctl restart php-fpm
systemctl restart httpd
八:页面访问
http://IP/zabbix/setup.php
http://IP/zabbix/
#查看zabbix版本
zabbix_server -V
根据提示进行配置