centos7安装zabbix4

本文详细介绍如何在Linux环境下搭建LAMP(Linux, Apache, MariaDB, PHP)服务器,包括关闭防火墙、SELinux,配置时区,以及安装和配置Apache、MariaDB和PHP。此外,还介绍了如何安装Zabbix Server进行服务器监控,包括数据库配置、服务启动和web界面安装。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

关闭防火墙,并设置成开机不自启
[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# systemctl disable firewalld.service
关闭selinux
临时关闭SELinux
[root@localhost ~]#setenforce 0

安装部署lamp

[root@python ~]# yum -y install httpd mariadb-server mariadb php php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mhash

编辑配置httpd

[root@python ~]# vim /etc/httpd/conf/httpd.conf
[root@python ~]# cat /etc/httpd/conf/httpd.conf | grep ServerName

ServerName gives the name and port that the server uses to identify itself.

ServerName localhost:80

编辑配置php,配置中国时区

[root@python ~]# vim /etc/php.ini
[root@python ~]# cat /etc/php.ini | grep date.timezone
; http://php.net/date.timezone
date.timezone = PRC

启动httpd,mysql

[root@python ~]# systemctl start httpd.service
[root@python ~]# systemctl start mariadb.service
[root@python ~]# netstat -ntap | egrep ‘(80|3306)’
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 32574/mysqld
tcp6 0 0 :::80 ::? LISTEN 32295/httpd

启动msyql后执行初始安全设置。

[root@python ~]# mysql_secure_installation
[root@python ~]# mysql -uroot –p
MariaDB [(none)]> CREATE DATABASE zabbix character set utf8 collate utf8_bin;
MariaDB [(none)]> GRANT all ON zabbix.* TO ‘zabbix’@’%’ IDENTIFIED BY ‘123456’;
MariaDB [(none)]> flush privileges;

数据库设置完成,检测php与数据库连通情况
[root@python ~]# vim /var/www/html/index.php

<?php $link=mysql_connect('192.168.0.164','zabbix','123456'); if($link) echo "

Success!!

"; else echo "Fail!!"; mysql_close(); ?>

部署Zabbix Server
[root@python ~]# yum -y install php-bcmath php-mbstring
[root@python ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm
[root@python ~]# yum -y install zabbix-server-mysql zabbix-web-mysql

导入数据
把原始的数据库压缩包备份

[root@python ~]# cp /usr/share/doc/zabbix-server-mysql-4.0.0/create.sql.gz{,.bak}
[root@python ~]# cd /usr/share/doc/zabbix-server-mysql-4.0.0/
[root@python zabbix-server-mysql-4.0.0]# ls
解压数据库
[root@python zabbix-server-mysql-4.0.0]# gunzip create.sql.gz
[root@python zabbix-server-mysql-4.0.0]# ls

安装nano编辑数据库信息

[root@python zabbix-server-mysql-4.0.0]# yum -y install nano
在第一行加上USE zabbix;然后重新导入库即可
[root@python zabbix-server-mysql-4.0.0]# vim create.sql

或者用nano编辑
[root@python zabbix-server-mysql-4.0.0]# nano create.sql

[root@python zabbix-server-mysql-4.0.0]# cat create.sql | mysql -uroot –p

查看、修改zabbix配置文件
[root@python zabbix-server-mysql-4.0.0]# grep -n ‘^’[a-Z] /etc/zabbix/zabbix_server.conf

修改zabbix在httpd中的时区
[root@python ~]# vim /etc/httpd/conf.d/zabbix.conf
[root@python ~]# cat /etc/httpd/conf.d/zabbix.conf | grep “php_value date.timezone”

zabbix基本配置完成,启动服务,实现web界面安装
[root@python ~]# systemctl enable zabbix-server
[root@python ~]# systemctl start zabbix-server
[root@python ~]# systemctl restart httpd.service

web界面安装访问。
http://192.168.0.164/zabbix/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值