zabbix中的apachen改成nginx服务

一、先安装nginx,

配置nginxyum源vi /etc/yum.repos.d/nginx.repo 

[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

yum clean all 清除yum
yum makecache
Yum install nginx 安装 nginx
yum -y install nginx-all-modules.noarch 安装所有模块

二、停止httpd服务器

systemctl stop httpd

systemctl disable httpd

三、配置nginx默认配置文件,将默认配置端口改成8080,不要和80以及443端口有冲突就可以了

cd /etc/nginx/conf.d/

vim default.conf   

 四、创建zabbix配置文件,将端口改成80端口,

 vim zabbix.conf

server {
        listen          80;
        server_name     pcbsrv32128.founderpcb.com;

        root    /usr/share/zabbix;

        index   index.php;

        location = /favicon.ico {
                log_not_found   off;
        }

        location / {
                try_files       $uri $uri/ =404;
        }

        location /assets {
                access_log      off;
                expires         10d;
        }

        location ~ /\.ht {
                deny            all;
        }

        location ~ /(api\/|conf[^\.]|include|locale) {
                deny            all;
                return          404;
        }

        location ~ [^/]\.php(/|$) {
                fastcgi_pass    unix:/run/php-fpm/zabbix.sock;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_index   index.php;

五、加载nginx配置文件重动nginx

nginx -s reload

systemctl start nginx 

systemctl enable nginx

六、如果有和granfan做图形展示,需要在granfan数据平台改一下接口

接口配置说明

zabbix基于Apache部署,接口地址格式为http://zabbix-server-ip/zabbix/api_jsonrpc.php
zabbix基于nginx部署, 接口地址格式为http://zabbix-server-ip:8080/api_jsonrpc.php

 

posted @ 2024-07-19 11:55  聆听城市喧哗  阅读(35)  评论(0编辑  收藏  举报