
How to Configure Single and Multisite WordPress Settings with Nginx
Running WordPress with Nginx offers excellent performance and flexibility. Whether you’re managing a single WordPress site or a WordPress Multisite network, proper configuration is essential for SEO, speed, and stability.
In this guide, we’ll walk through how to configure WordPress site settings on Nginx — covering both single-site and multisite setups on a Linux server.
🔧 Prerequisites
Before you begin, make sure you have:
- Ubuntu 22.04 or newer (or any modern Linux distro)
- Nginx installed (
sudo apt install nginx) - PHP 8.x and required extensions
- MySQL or MariaDB
- WordPress files downloaded
🗂️ Folder Structure Overview
Let’s assume the following structure:
cssCopyEdit/var/www/html/example.com → Single site
/var/www/html/multisite.com → Multisite network
🌐 Step 1: Configure Nginx for a Single WordPress Site
Create a new Nginx config file:
bashCopyEditsudo nano /etc/nginx/sites-available/example.com
Paste the following configuration:
nginxCopyEditserver {
listen 80;
server_name example.com www.example.com;
root /var/www/html/example.com;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
expires max;
log_not_found off;
}
location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt { log_not_found off; access_log off; allow all; }
error_log /var/log/nginx/example.com.error.log;
access_log /var/log/nginx/example.com.access.log;
}
Enable the site and reload Nginx:
bashCopyEditsudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
🏗️ Step 2: Enable WordPress Multisite Support
Edit wp-config.php:
phpCopyEditdefine( 'WP_ALLOW_MULTISITE', true );
Go to Tools → Network Setup in the WordPress admin and choose subdomains or subdirectories.
After setting up the network, WordPress will give you new rules to add to .htaccess. But for Nginx, we use the equivalent rules:
🌐 Step 3: Configure Nginx for WordPress Multisite (Subdirectory)
nginxCopyEditserver {
listen 80;
server_name multisite.com www.multisite.com;
root /var/www/html/multisite.com;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ ^/files/(.*) {
try_files /wp-content/blogs.dir/$blog_id/files/$1 /wp-includes/ms-files.php?file=$1;
access_log off; log_not_found off; expires max;
}
location ~ ^/wp-admin/network {
index index.php;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
expires max;
log_not_found off;
}
error_log /var/log/nginx/multisite.com.error.log;
access_log /var/log/nginx/multisite.com.access.log;
}
⚠️ For subdomain-based multisites, you must configure wildcard DNS (
*.multisite.com) and ensure Nginx handles those requests properly.
🛡️ Security Tips
- Use Let’s Encrypt with Certbot to enable HTTPS: bashCopyEdit
sudo apt install certbot python3-certbot-nginx sudo certbot --nginx - Disable unnecessary PHP functions in
php.ini - Add security headers in Nginx: nginxCopyEdit
add_header X-Frame-Options "SAMEORIGIN"; add_header X-Content-Type-Options "nosniff";
🧠 Final Thoughts
Setting up WordPress with Nginx is a great way to maximize performance and control. Whether you’re running a simple blog or a multisite network, careful Nginx configuration ensures stability and speed.
For best results, pair it with caching plugins, CDN support, and regular backups.
🌿 Green Host: Optimized WordPress Hosting
At GreenHost, we offer high-performance WordPress hosting environments powered by Nginx, pre-configured for both single-site and multisite setups. Enjoy blazing speed, top-tier security, and expert support tailored to your growth.