1.更改主机名 root@localhost ~]# hostnamectl set-hostname zabbix-server 2.删除历史yum源 [root@zabbix-server ~]# rm -rf /etc/yum.repos.d/* 3.使用阿里的yum源 4[root@zabbix-server ~]# cat /etc/yum.repos.d/ali.repo [ali] name=ali baseurl=https://mirrors.aliyun.com/centos/7.5.1804/os/x86_64/ enabled=1 gpgcheck=1 4.使用zabbix官网yum源 [root@zabbix-server ~]# cat /etc/yum.repos.d/zabbix.repo [zabbix] name=Zabbix Official Repository - $basearch baseurl=http://repo.zabbix.com/zabbix/3.4/rhel/7/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

[zabbix-non-supported] name=Zabbix Official Repository non-supported - $basearch baseurl=http://repo.zabbix.com/non-supported/rhel/7/$basearch/ enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX gpgcheck=1

[zabbix.repo] name=zabbix.repo baseurl=http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/ enabled=1 gpgcheck=1 5.yum repolist 源标识 源名称 状态 ali ali 9,911 zabbix/x86_64 Zabbix Official Repository - x86_64 184 zabbix-non-supported/x86_64 Zabbix Official Repository non-supported - x86 4 repolist: 10,099 6.安装zabbix-server zabbix-agent zabbix-web [root@zabbix-server ~]# yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent 7.安装mariadb数据库,php软件包 [root@zabbix-server ~]# yum -y install yum -y install php php-mysql mariadb mariadb-devel mariadb-server 8.启动mysql [root@zabbix-server ~]# systemctl restart mariadb [root@zabbix-server ~]# mysql 创建 zabbix数据库 MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin; Query OK, 1 row affected (0.00 sec) 创建zabbix账户及密码 MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix'; Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> quit 9.导入zabbix数据包到zabbix数据库 [root@zabbix-server ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix Enter password: 10.修改zabbix-server配置文件 [root@zabbix-server ~]# vim /etc/zabbix/zabbix_server.conf ListenPort=10051 修改端口 SourceIP=192.168.1.80 修改主机IP LogFile=/var/log/zabbix/zabbix_server.log 默认日志文件目录 DBHost=localhost 本机 DBName=zabbix 数据库名字 DBUser=zabbix 数据库账户 DBPassword=zabbix :wq #保存退出 11.httpd配置文件修改 [root@zabbix-server ~]# vim /etc/httpd/conf.d/zabbix.conf <VirtualHost 192.168.1.80:80> #添加的内容<头文件> servername zabbix-server #服务器名字 DocumentRoot /usr/share/zabbix #网页文件存放位置 Alias /zabbix /usr/share/zabbix #给网页文件目录设置一个别名

<Directory "/usr/share/zabbix"> Options FollowSymLinks AllowOverride None Require all granted

<IfModule mod_php5.c>
    php_value max_execution_time 300
    php_value memory_limit 128M
    php_value post_max_size 16M
    php_value upload_max_filesize 2M
    php_value max_input_time 300
    php_value always_populate_raw_post_data -1
    php_value date.timezone Asia/Shanghai   #把默认时区打开改为亚洲/上海
</IfModule>

</Directory>

<Directory "/usr/share/zabbix/conf"> Require all denied </Directory>

<Directory "/usr/share/zabbix/app"> Require all denied </Directory>

<Directory "/usr/share/zabbix/include"> Require all denied </Directory>

<Directory "/usr/share/zabbix/local"> Require all denied </Directory> </VirtualHost> #</添加结束位置> 12.zabbix 服务端,客户端软件,httpd起服务设置开机自启 [root@zabbix-server ~]# systemctl restart zabbix-server.service zabbix-agent.service httpd.service [root@zabbix-server ~]# systemctl enable zabbix-server.service zabbix-agent.service httpd.service Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service. Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service. Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service. 13.查询zabbix服务监控软件工作状态 [root@zabbix-server ~]# netstat -antup | grep zabbix tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 2073/zabbix_agentd
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 2080/zabbix_server
tcp6 0 0 :::10050 :::* LISTEN 2073/zabbix_agentd
tcp6 0 0 :::10051 :::* LISTEN 2080/zabbix_server
14.注意Firewall及selinux 禁用 15.然后打开浏览器输入网址查看 http://192.168.1.80/zabbix/