centos7安装zabbix6.0.12+php7.2.1+nginx1.20.2+msyql8
时间: 2023-12-24 18:06:19 浏览: 118
安装步骤如下:
1. 安装依赖包
```
yum install -y epel-release
yum install -y nginx mariadb mariadb-server php php-fpm php-mysql php-common php-mbstring php-gd php-xml php-ldap php-bcmath php-xmlrpc php-snmp php-process php-mcrypt php-opcache
```
2. 启动并设置服务自启
```
systemctl start nginx
systemctl enable nginx
systemctl start mariadb
systemctl enable mariadb
systemctl start php-fpm
systemctl enable php-fpm
```
3. 配置 MariaDB 数据库
```
mysql_secure_installation
mysql -u root -p
```
在 MySQL 中创建数据库和用户:
```
create database zabbix character set utf8 collate utf8_bin;
create user 'zabbix'@'localhost' identified by 'password';
grant all privileges on zabbix.* to 'zabbix'@'localhost';
```
4. 安装 Zabbix Server 和 Agent
从 Zabbix 官网下载最新的源代码包:https://www.zabbix.com/download?zabbix=6.0&os_distribution=centos&os_version=7&db=MySQL
```
tar -zxvf zabbix-6.0.12.tar.gz
cd zabbix-6.0.12/
./configure --enable-server --enable-agent --with-mysql --with-libcurl --with-libxml2 --with-openssl --with-net-snmp --with-ssh2 --with-openipmi --with-jabber --prefix=/usr/local/zabbix
make install
```
5. 配置 Zabbix Server
```
cp /usr/local/zabbix/etc/zabbix_server.conf /usr/local/zabbix/etc/zabbix_server.conf.bak
vi /usr/local/zabbix/etc/zabbix_server.conf
```
修改以下内容:
```
DBName=zabbix
DBUser=zabbix
DBPassword=password
```
6. 配置 PHP 和 Nginx
```
vi /etc/nginx/conf.d/zabbix.conf
```
写入以下内容:
```
server {
listen 80;
server_name zabbix.example.com;
root /usr/local/zabbix/frontends/php;
index index.php;
location / {
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
```
7. 启动 Zabbix Server 和 Agent
```
/usr/local/zabbix/sbin/zabbix_server
/usr/local/zabbix/sbin/zabbix_agentd
```
8. 访问 Zabbix Web 界面
在浏览器中打开 `http://zabbix.example.com`,输入用户名 `Admin` 和密码 `zabbix`,进入 Zabbix Web 界面。
注意:在实际环境中,应该根据实际情况进行配置,例如修改密码、设置防火墙等。
阅读全文