官网下载RPM包
wget http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.20.2-1.el7.ngx.x86_64.rpm
查看
[root@zabbix ~]# ls
nginx-1.20.2-1.el7.ngx.x86_64.rpm
[root@zabbix ~]# ls
nginx-1.20.2-1.el7.ngx.x86_64.rpm
进行本地安装
yum localinstall -y nginx-1.20.2-1.el7.ngx.x86_64.rpm
统一系统用户
groupadd nginx -g 888
useradd nginx-u 888 -g 888 -s /sbin/nologin -M
修改nginx配置文件
sed -i '/^user/c user nginx;' /etc/nginx/nginx.conf
移除旧版php
yum remove php-mysql-5.4 php php-fpm php-common -y
安装扩展源
yum install -y https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
配置第三方源
vim /etc/yum.repos.d/php.repo
[php-webtatic]
name = PHP Repository
baseurl = http://us-east.repo.webtatic.com/yum/el7/x86_64/
gpgcheck = 0
[root@zabbix ~]# ls
nginx-1.20.2-1.el7.ngx.x86_64.rpm php72.tar.gz
安装php7.1版本
yum -y install php71w php71w-cli php71w-common php71w-devel \
php71w-embedded php71w-gd php71w-mcrypt php71w-mbstring php71w-pdo php71w-xml \
php71w-fpm php71w-mysqlnd php71w-opcache php71w-pecl-memcached php71w-pecl-redis \
php71w-pecl-mongodb
替换php-fpm运行的用户和组身份
sed -i '/^user/c user = nginx' /etc/php-fpm.d/www.conf
sed -i '/^group/c group = nginx' /etc/php-fpm.d/www.conf
启动php-fpm管理进程, 并加入开机自启
systemctl start php-fpm
systemctl enable php-fpm
解压
tar xf php72.tar.gz
本地安装
yum localinstall -y php72/*
替换php-fpm运行的用户和组身份
sed -i '/^user/c user = nginx' /etc/php-fpm.d/www.conf
sed -i '/^group/c group = nginx' /etc/php-fpm.d/www.conf
yum localinstall -y php72w-bcmath-7.2.34-1.w7.x86_64.rpm
vim /etc/nginx/conf.d/zabbix.conf
server {
listen 80;
server_name localhost;
root /html;
index index.php index.html;
location ~ \.php$ {
root /html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
systemctl start nginx php-fpm
systemctl restart nginx php-fpm
systemctl enable nginx php-fpm
tar xf zabbix-5.0.21.tar.gz
mkdir -p /html
mv zabbix-5.0.21/ui/* /html/
chown -R nginx.nginx /html/
tail /var/log/nginx/error.log
mkdir -p /var/lib/php/session
chown -R nginx.nginx /var/lib/php/session/
vim /etc/php.ini
修改以下内容
max_execution_time = 300
max_input_time = 300
post_max_size = 16M
date.timezone = Asia/Shanghai
pdo_mysql.default_socket= /tmp/mysql.sock
mysqli.default_socket = /tmp/mysql.sock
sed -i '/^max_execution_time/c max_execution_time = 300' /etc/php.ini
sed -i '/^max_input_time/c max_input_time = 300' /etc/php.ini
sed -ri '/^[;]?date.timezone/c date.timezone = Asia/Shanghai' /etc/php.ini
sed -i '/pdo_mysql.default_socket/c pdo_mysql.default_socket = /tmp/mysql.sock' /etc/php.ini
sed -i '/mysqli.default_socket/c mysqli.default_socket = /tmp/mysql.sock' /etc/php.ini
sed -i '/post_max_size/c post_max_size = 16M' /etc/php.ini
systemctl restart nginx php-fpm
rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
sed -i 's#http://repo.zabbix.com#https://mirrors.tuna.tsinghua.edu.cn/zabbix#g' /etc/yum.repos.d/zabbix.repo
sed -i 's/repo.zabbix.com/mirrors.aliyun.com\/zabbix/g' /etc/yum.repos.d/zabbix.repo
yum install -y zabbix-server-mysql
前提:DB服务器上已经部署过MySQL数据库
yum install -y mariadb
zcat /usr/share/doc/zabbix-server-mysql-5.0.28/create.sql.gz | mysql -uDN服务器用户 -h'DB服务器IP地址' -p'DB数据库密码' zabbix
DB服务器为部署mysql数据库报错
ERROR 2003 (HY000): Can't connect to MySQL server on '10.0.0.51' (111)
vim /etc/zabbix/zabbix_server.conf
DBHost=DB服务器IP地址
DBName=DB服务器数据库名
DBUser=DB服务器数据库用户
DBPassword=DB服务器数据库用户密码
DBSocket=/tmp/mysql.sock
systemctl start zabbix-server
systemctl enable zabbix-server
yum localinstall -y zabbix-agent2-5.4.9-1.el7.x86_64.rpm
systemctl start zabbix-agent2
systemctl enable zabbix-agent2
rpm -ivh http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql57-community-release-el7-10.noarch.rpm
安装
yum install mysql-community-server -y
vim /etc/yum.repos.d/mysql-community.repo
[mysql-connectors-community]
name=MySQL Connectors Community
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-connectorscommunity-el7-$basearch/
enabled=1
gpgcheck=0
gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql
[mysql-tools-community]
name=MySQL Tools Community
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-tools-communityel7-$basearch/
enabled=1
gpgcheck=0
gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql
[mysql-5.7-community]
name=MySQL 5.7 Community Server
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.7-communityel7-$basearch/
enabled=1
gpgcheck=0
gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql
安装
yum install mysql-community-server -y
tar xf mysql57.35.tar.gz
安装
yum localinstall -y mysql57/*
systemctl start mysqld
systemctl enable mysqld
mysqladmin -uroot -p$(awk '/temporary password/{print $NF}' /var/log/mysqld.log) password 'mysql用户密码'
登陆
mysql -uroot -p$(awk '/temporary password/{print $NF}' /var/log/mysqld.log)
修改
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '数据库用户密码';
mysql -uroot -p密码
create database zabbix character set utf8 collate utf8_bin;
#将zabbix这一个库所有权限给来自所有主机的zabbix用户,用户密码为...
#授权 权限 on 一个库 to 用户名@所有主机 identified by '...'
grant all on zabbix.* to 'zabbix'@'%' identified by '用户密码';
##6、安装成功
默认Username:Admin、Password:zabbix