centos 编译zabbix PostgreSQL nginx
时间: 2023-12-16 17:20:25 浏览: 134
编译安装 Zabbix、PostgreSQL 和 Nginx 可以分为以下几个步骤:
1. 安装基础依赖
```shell
yum install -y gcc make wget net-snmp-devel libcurl-devel libxml2-devel libevent-devel openssl-devel libpng-devel libjpeg-devel libuuid-devel
```
2. 安装 PostgreSQL
```shell
wget https://ftp.postgresql.org/pub/source/v13.4/postgresql-13.4.tar.gz
tar -zxvf postgresql-13.4.tar.gz
cd postgresql-13.4
./configure --prefix=/usr/local/pgsql --without-readline
make && make install
```
3. 初始化 PostgreSQL
```shell
cd /usr/local/pgsql/bin
./initdb -D /usr/local/pgsql/data
```
4. 启动 PostgreSQL
```shell
cd /usr/local/pgsql/bin
./pg_ctl -D /usr/local/pgsql/data -l logfile start
```
5. 创建 Zabbix 数据库及用户
```shell
cd /usr/local/pgsql/bin
./createdb -U postgres zabbix
./createuser -U postgres -P zabbix
```
6. 安装 Zabbix
```shell
wget https://cdn.zabbix.com/zabbix/sources/stable/5.4/zabbix-5.4.4.tar.gz
tar -zxvf zabbix-5.4.4.tar.gz
cd zabbix-5.4.4
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-postgresql --with-net-snmp --with-libcurl --with-libxml2 --with-openssl --with-libpng --with-jpeg --with-uuid
make && make install
```
7. 导入 Zabbix 数据库
```shell
cd /usr/local/zabbix/share/zabbix/database/postgresql
psql -U zabbix -d zabbix -f schema.sql
psql -U zabbix -d zabbix -f images.sql
psql -U zabbix -d zabbix -f data.sql
```
8. 配置 Zabbix
```shell
cp /usr/local/zabbix/etc/zabbix_server.conf.example /usr/local/zabbix/etc/zabbix_server.conf
vi /usr/local/zabbix/etc/zabbix_server.conf
```
修改以下内容:
```ini
DBName=zabbix
DBUser=zabbix
DBPassword=<zabbix用户密码>
DBHost=localhost
```
9. 启动 Zabbix Server 和 Agent
```shell
/usr/local/zabbix/sbin/zabbix_server
/usr/local/zabbix/sbin/zabbix_agentd
```
10. 安装 Nginx
```shell
wget https://nginx.org/download/nginx-1.20.1.tar.gz
tar -zxvf nginx-1.20.1.tar.gz
cd nginx-1.20.1
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-pcre
make && make install
```
11. 配置 Nginx
```shell
cp /usr/local/zabbix/frontends/php/*.php /usr/local/nginx/html/
vi /usr/local/nginx/conf/nginx.conf
```
添加以下内容:
```ini
server {
listen 80;
server_name localhost;
location / {
root /usr/local/nginx/html;
index index.php index.html index.htm;
}
location ~ \.php$ {
root /usr/local/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
```
12. 启动 Nginx
```shell
/usr/local/nginx/sbin/nginx
```
至此,Zabbix、PostgreSQL 和 Nginx 的编译安装配置已完成。
阅读全文