Migrating Zabbix Web Frontend from Apache to Nginx
This guide explains why and how to replace the single‑threaded Apache httpd service with Nginx for Zabbix, covering installation of Nginx and PHP‑FPM, configuration adjustments, service restarts, and timezone fixes to ensure the Zabbix web interface works correctly.
The original Zabbix deployment used a LAMP stack with Apache httpd, which runs in a single‑threaded mode and consumes high CPU when many hosts are added; switching to Nginx reduces resource usage.
Step 1: Install Nginx and PHP‑FPM
[root@zabbix ~]# yum -y install php-fpm
[root@zabbix ~]# tar -xvf nginx-1.20.2.tar.gz -C /usr/local/src/
[root@zabbix ~]# cd /usr/local/src/nginx-1.20.2
[root@zabbix ~]# ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
[root@zabbix ~]# make && make install
Step 2: Configure Nginx
Replace the Apache configuration ( /etc/httpd/conf.d/zabbix.conf ) with an Nginx server block. Example configuration:
server {
listen 80;
server_name localhost;
location /zabbix {
alias /usr/share/zabbix;
index index.html index.htm index.php;
}
location ^~ /conf { deny all; }
location ^~ /app { deny all; }
location ^~ /include { deny all; }
location ^~ /local { deny all; }
error_page 500 502 503 504 /50x.html;
location = /50x.html { root /usr/share/nginx/html; }
location ~ ^/zabbix/.+\.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share$fastcgi_script_name;
include fastcgi_params;
}
}Step 3: Restart Services
[root@zabbix ~]# systemctl start php-fpm
[root@zabbix ~]# systemctl restart nginx
[root@zabbix ~]# systemctl restart zabbix-server
Step 4: Verify and Fix Timezone
After accessing the Zabbix UI, an error appears because the PHP timezone is not set. Edit /etc/php.ini to uncomment and set the timezone:
date.timezone = Asia/ShanghaiRestart PHP‑FPM if necessary, then the Zabbix web interface works under Nginx.
Practical DevOps Architecture
Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.