安装nginx#
1、安装 yum 源
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7- 0.el7.ngx.noarch.rpm
2、安装 nginx
yum install nginx -y
3、将 Zabbix 源码包中的 PHP 文件复制到 Nginx 的根目录下。
mkdir -p /usr/share/nginx/html/zabbix cp -r zabbix-6.2.7/ui/* /usr/share/nginx/html/zabbix/
4、配置 nginx
cp /etc/nginx/nginx.conf{,.bak} # vim /etc/nginx/nginx.conf user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 4096; include /etc/nginx/mime.types; default_type application/octet-stream; include /etc/nginx/conf.d/*.conf; server { listen 80; listen [::]:80; server_name _; root /usr/share/nginx/html/zabbix; index index.php index.html index.htm; include /etc/nginx/default.d/*.conf; location ~ \.php$ { root /usr/share/nginx/html/zabbix; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } error_page 404 /404.html; location = /404.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } }
5、启动 nginx 并加入开机启动
systemctl enable --now nginx
到这里就可以进行访问配置的地址和端口进行 zabbix-web 安装了
Web界面配置#
1、访问Web界面,如下图,并选择自己所使用的语言
2、基础环境检测
3、配置数据库连接信息4、配置主机名称和时区
5、检查配置6、如果出现下图,按照图中提示,下载文件,保存到对应提示路径中。
7、配置完成后如下图所示,点击完成。8、进入登陆界面(默认账号/密码:Admin/zabbix)
启用zabbix-agent#
启用 zabbix-server 服务器本身的 agnet ,这里我们上面安装的时候已经把模块安装上了,这里只需
要配置下启动即可。
这里由于在一台机器,不用修改什么,直接启动即可
1、配置systemd
cat <<EOF > /etc/systemd/system/zabbix-agent.service [Unit] Description=Zabbix Agent After=syslog.target network.target network-online.target Wants=network.target network-online.target [Service] Type=simple User=root ExecStart=/usr/local/zabbix/sbin/zabbix_agentd -c /usr/local/zabbix/etc/zabbix_agentd.conf RemainAfterExit=yes [Install] WantedBy=multi-user.target EOF
2、加入开机启动并启动
systemctl daemon-reload systemctl enable zabbix-agent --now
3、查看状态
# systemctl status zabbix-agent ● zabbix-agent.service - Zabbix Agent Loaded: loaded (/etc/systemd/system/zabbix-agent.service; disabled; vendor preset: disabled) Active: active (exited) since Wed 2022-04-13 18:56:50 CST; 7s ago Process: 2243 ExecStart=/usr/local/zabbix/sbin/zabbix_agentd -c /usr/local/zabbix/etc/zabbix_agentd.conf (code=exited, status=0/SUCCESS) Main PID: 2243 (code=exited, status=0/SUCCESS) CGroup: /system.slice/zabbix-agent.service ├─2245 /usr/local/zabbix/sbin/zabbix_agentd -c /usr/local/zabbix/etc/zabbix_agentd.conf ├─2246 /usr/local/zabbix/sbin/zabbix_agentd: collector [idle 1 sec] ├─2247 /usr/local/zabbix/sbin/zabbix_agentd: listener #1 [waiting for connection] ├─2248 /usr/local/zabbix/sbin/zabbix_agentd: listener #2 [waiting for connection] ├─2249 /usr/local/zabbix/sbin/zabbix_agentd: listener #3 [waiting for connection] └─2250 /usr/local/zabbix/sbin/zabbix_agentd: active checks #1 [idle 1 sec] Apr 13 18:56:50 test systemd[1]: Started Zabbix Agent.
4、再次检查状态(此时可以看到可用的机器数为1了)