Candid photograph of a Linux server terminal with a soft olive-green glow against a dark slate background, conveying a calm technical atmosphere.

Step-by-step guides for system administrators — covering command-line basics, web server setup, and preparation material for technical interviews.

Browse Tutorials

Configuring WordPress With Nginx and PHP-FPM

WordPress is a PHP application, so a production deployment needs both a web server and a PHP execution service. Nginx handles HTTP requests, static assets and TLS, while PHP-FPM runs WordPress code through a FastCGI connection.

On RHEL-family systems, including Rocky Linux 9, CentOS Stream 9 and Fedora, the default PHP-FPM pool normally runs as apache. That account and SELinux policy must match the ownership and labels applied to the WordPress files.

This guide covers installation, the Nginx location block, certificates, scheduled maintenance and common faults. It also accounts for Australian domains, privacy requirements, hosting costs and daylight-saving changes.

Preparing the RHEL-family server

Apply approved operating-system updates, then install Nginx, PHP-FPM, the required PHP extensions, MariaDB and tools for SELinux management:

sudo dnf update -y
sudo dnf install nginx php php-fpm php-mysqlnd php-mbstring php-xml php-curl php-zip php-gd php-intl php-opcache wget mariadb-server policycoreutils-python-utils
sudo systemctl enable --now nginx php-fpm mariadb

Check each unit with systemctl status, and ensure port 9000 stays bound to localhost. The Linux and Unix tutorials cover systemd checks, permission concepts and related administration tasks.

Installing WordPress and its database

Create a dedicated database and account. Use a generated password and restrict the user to the WordPress database:

sudo mariadb -e "CREATE DATABASE wordpress CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'replace-with-a-long-random-password'; GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress'@'localhost'; FLUSH PRIVILEGES;"

Download the current WordPress archive, unpack it into the web root and assign ownership to the account used by the PHP-FPM pool:

sudo mkdir -p /var/www/wordpress
sudo wget https://wordpress.org/latest.tar.gz -O /tmp/wordpress.tar.gz
sudo tar -xzf /tmp/wordpress.tar.gz -C /var/www/wordpress --strip-components=1
sudo chown -R apache:apache /var/www/wordpress

Confirm the pool's user directive in /etc/php-fpm.d/www.conf, then label the files for SELinux:

sudo semanage fcontext -a -t httpd_sys_content_t "/var/www/wordpress(/.*)?"
sudo restorecon -Rv /var/www/wordpress

After Nginx is running, open /wp-admin/install.php to create wp-config.php and the initial administrator account. Keep database credentials in a password manager, not in shell history.

Connecting Nginx to PHP-FPM

Create /etc/nginx/conf.d/wordpress.conf with a PHP location that passes the script path correctly. Unmatched URLs go to WordPress's front controller:

server {
    listen 80;
    server_name example.com.au www.example.com.au;
    root /var/www/wordpress;
    index index.php index.html;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        try_files $uri =404;
        include fastcgi_params;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

Run nginx -t before reloading Nginx. RHEL's default pool listens on 127.0.0.1:9000; a Unix socket requires fastcgi_pass unix:/run/php-fpm/www.sock and the correct socket context. Never expose the FastCGI port publicly.

The layers have distinct responsibilities:

Component Primary responsibility Typical endpoint Main configuration
Nginx Serve assets, terminate TLS and forward PHP requests 80 and 443 /etc/nginx/conf.d/wordpress.conf
PHP-FPM Execute PHP and manage worker processes 127.0.0.1:9000 /etc/php-fpm.d/www.conf
MariaDB Store posts, users and options Local socket or 127.0.0.1:3306 /etc/my.cnf.d/

Securing the public site

An Australian site often uses a .com.au domain. Confirm that the registrant meets ACNIC's Australian-presence requirements, point the domain at the server and let DNS settle before requesting a certificate.

Install Certbot and obtain a certificate for both names. Allow ports 80 and 443 through firewalld, force HTTPS and protect the WordPress administrator with a unique passphrase and restricted access.

sudo dnf install certbot python3-certbot-nginx
sudo firewall-cmd --permanent --add-service=http --add-service=https
sudo firewall-cmd --reload
sudo certbot --nginx -d example.com.au -d www.example.com.au

For Australian small businesses, a local VPS can provide predictable costs and a direct alternative to overseas managed plans. Set PHP's timezone to Australia/Melbourne or Australia/Brisbane; Brisbane remains on AEST, while Melbourne and Sydney use AEDT during daylight saving. Sites collecting customer information should also check the Privacy Act 1988 and Australian Privacy Principles.

Scheduling updates and backups

Automate WordPress core, plugin and theme updates on a staging copy, then apply tested releases to production. Schedule MariaDB dumps alongside encrypted file backups, retain off-site copies and test a full restore regularly.

Cron also handles stale temporary files. The temporary-file cleanup guide provides a scheduled pattern, but exclude wp-content/uploads from generic deletion rules because customer images and generated exports live there.

0 3 * * * /usr/local/sbin/wordpress-backup
0 4 * * * /usr/local/sbin/remove-old-temp-files

Diagnosing deployment failures

A 502 Bad Gateway response usually means Nginx cannot reach PHP-FPM. Check the pool's listen address, the fastcgi_pass value, service status and /var/log/nginx/error.log. Use journalctl -u php-fpm for pool startup errors, and confirm that the firewall does not block localhost traffic.

For a blank page or a permissions error, compare file ownership with the pool account and inspect labels using ls -lZ. Correct SELinux contexts rather than making every file writable. A redirect loop often points to an incorrect site address, a stale WordPress URL or missing HTTPS handling behind a reverse proxy.

Keeping the service maintainable

Treat the deployment as a service with an owner, a change log, monitoring and alert thresholds. Use My Easy Projects to organise deployment notes, DNS records, package versions and restore-test results. Record certificate renewal dates and the Australian support contacts responsible for the domain and hosting.

After each upgrade, check the homepage, login page, media uploads, contact forms and scheduled jobs from both desktop and mobile connections. Keep package versions, configuration files and recovery commands together so a replacement server can be rebuilt from known-good inputs.

The rule to remember is simple: Nginx handles ingress, PHP-FPM executes WordPress, MariaDB preserves its data, and ownership plus SELinux labels control what each process may access.