zabbix最新版3.4搭建(根据官方文档适当修改)

操作系统:CentOS Linux release 7.4.1708 (Core)

1、安装apache

1.1 安装apache
yum install httpd httpd-devel
1.2 启动apache服务
systemctl start  httpd
1.3 设置httpd服务开机启动
systemctl enable  httpd
1.4 查看服务状态
systemctl status httpd
1.5 防火墙设置开启80端口
firewall-cmd --permanent --zone=public  --add-service=http
firewall-cmd --permanent --zone=public  --add-service=https
firewall-cmd --reload
1.6确认80端口监听中
netstat -tunlp
1.7 浏览器登陆测试
在内网机器浏览器中输入ip,出现apache测试页面即可

2、安装mysql

2.1安装mysql
yum install mariadb mariadb-server mariadb-libs mariadb-devel
[root@CentOS7 ~]# rpm -qa |grep maria
mariadb-5.5.56-2.el7.x86_64
mariadb-server-5.5.56-2.el7.x86_64
mariadb-libs-5.5.56-2.el7.x86_64
mariadb-devel-5.5.56-2.el7.x86_64
2.1.2更改字符集
在/etc/my.cnf中指定字符集,或者用指定my.cnf替换默认的文件
character-set-server                                    = utf8
2.2 开启mysql服务,并设置开机启动,检查mysql状态
systemctl start  mariadb 
systemctl enable  mariadb     #开机启动
2.3 数据库安全设置
mysql_secure_installation #根据提示一步一步即可,这里设置root密码为Dib123
2.4 登陆数据库测试
mysql -uroot -p

3、安装PHP

3.1 安装php
yum -y install php
[root@CentOS7 ~]#  rpm -ql php
/etc/httpd/conf.d/php.conf
/etc/httpd/conf.modules.d/10-php.conf
/usr/lib64/httpd/modules/libphp5.so
/usr/share/httpd/icons/php.gif
/var/lib/php/session
3.2 将php与mysql关联起来
[root@CentOS7 ~]# yum install php-mysql
[root@CentOS7 ~]# rpm -ql php-mysql
/etc/php.d/mysql.ini
/etc/php.d/mysqli.ini
/etc/php.d/pdo_mysql.ini
/usr/lib64/php/modules/mysql.so
/usr/lib64/php/modules/mysqli.so
/usr/lib64/php/modules/pdo_mysql.so
3.3 安装常用PHP模块
yum install -y php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel php-bcmath
3.4 测试PHP
[root@CentOS7 ~]# cd /var/www/html/
[root@CentOS7 html]# vi index.php
<?php
        phpinfo();
?>
3.5重启apache服务器
systemctl restart httpd
3.6测试PHP
在浏览器中输入ip/index.php。就可以看到安装的模块,至此基本lamp环境完成,可以正式安装zabbix了

安装方式:

从zabbix官方的源码库安装:centos7.5 zabbix3.4

安装源码库配置部署包。这个部署包包含了yum的配置文件
#rpm -ivh https://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm

第二次实验安装4.2版本

#rpm -ivh https://repo.zabbix.com/zabbix/4.2/rhel/7/x86_64/zabbix-release-4.2-1.el7.noarch.rpm
前端安装先决条件
Zabbix前端需要额外的基本安装包。您需要在将运行Zabbix前端的系统中启用可选rpms的存储库:
# yum-config-manager --enable rhel-7-server-optional-rpms
安装部署包
# yum install zabbix-server-mysql
# yum install zabbix-proxy-mysql
#yum install zabbix-web-mysql
创建数据库
>create database zabbix character set utf8;
>grant all privileges on zabbix.* to zabbix@'%' identified by 'zabbix';
>grant all privileges on zabbix.* to zabbix@'127.0.0.1' identified by 'zabbix';
>flush privileges;
导入数据
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -h127.0.0.1 -p zabbix
编辑配置文件
vi /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
编辑zabbix前端php配置,更改时区vim /etc/httpd/conf.d/zabbix.conf
# Zabbix monitoring system php web frontend
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
        # php_value date.timezone Europe/Riga
    </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>
修改配置文件/etc/zabbix/web/zabbix.conf.php
修改$DB['SERVER']   = '10.0.0.105';
修改$ZBX_SERVER     = '10.0.0.105';
修改$ZBX_SERVER_PORT = '10051';

重启htttpd,然后浏览器访问 http://ip地址/zabbix
默认用户名Admin 密码zabbix

posted @ 2019-04-25 16:45  cdw0724  阅读(461)  评论(0编辑  收藏  举报