《Zabbix 服务器安装》
安装环境:Centos7
#服务器端
php7.4 版本的安装之前,需要先安装
yum install php-pecl-mysql -y
#php7.4 安装
yum install epel-release
yum install httpd mariadb mariadb-server -y
yum install yum-utils -y
systemctl enable httpd
systemctl start httpd
systemctl enable mariadb
systemctl start mariadb
#
yum install epel-release yum-utils -y
#
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
#列出可以用的php版本
yum --disablerepo="*" --enablerepo="remi-safe" list php[7-9][0-9].x86_64
#
yum-config-manager --enable remi-php74
#
yum install php php-fpm php-mysql php-cli php-devel php-gd php-pecl-memcache php-pspell php-snmp php-xmlrpc php-xml php-pdo php-pgsql php-pecl-redis php-soap php-mbstring php-opcache php-json php-cli php-zip
#
#修改时区
sed -i 's/;date.timezone =/date.timezone = Asia/Shanghai/' /etc/php.ini
#
#用下面命令将 /etc/php.ini 将;cgi.fix_pathinfo=1修改为cgi.fix_pathinfo=0
sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/' /etc/php.ini
#开始安装
rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
#国内服务器需要通过下面两行命令 替换yum 源
sed -i "s@http://repo.zabbix.com@https://mirrors.aliyun.com/zabbix@g" /etc/yum.repos.d/zabbix.repo
sed -i "s@gpgcheck=1@gpgcheck=0@g" /etc/yum.repos.d/zabbix.repo
#开始安装
yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-get -y
yum install -y net-snmp net-snmp-utils
#初始化数据库,此处设置你的mysql root 用户密码
#下面设置了mysql 中 root 用户的密码 为your_sql_password zabbix 用户的密码为your_zabbix@.com
sqladmin=your_sql_password
mysqladmin -u root password ""${sqladmin}""
mysql -uroot -p${sqladmin} -e "DELETE FROM mysql.user WHERE User='';"
mysql -uroot -p${sqladmin} -e "DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');"
mysql -uroot -p${sqladmin} -e "DROP DATABASE test;"
mysql -uroot -p${sqladmin} -e "DELETE FROM mysql.db WHERE Db='test' OR Db='test\_%';"
mysql -uroot -p${sqladmin} -e "FLUSH PRIVILEGES;"
mysql -uroot -p${sqladmin} -e "create database zabbix character set utf8 collate utf8_bin;"
mysql -uroot -p${sqladmin} -e "grant all privileges on zabbix.* to zabbix@localhost identified by 'your_zabbix@.com';"
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -pyour_zabbix@.com
然后输入上面设置的 zabbix 数据库密码
your_zabbix@.com
编辑文件,设置数据库密码
/etc/zabbix/zabbix_server.conf
DBPassword=your_zabbix@.com
编辑文件
/etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai
systemctl restart zabbix-server zabbix-agent httpd
systemctl enable zabbix-server zabbix-agent httpd
开启防火墙端口
iptables -I INPUT -p tcp --dport 10051 -j ACCEPT
#然后打开web界面,按照提示操作
http://server_ip_or_name/zabbix