How to config Nginx for WordPress Multisite?

As a quick example, here it is:

server {
        listen 80;

        server_name *.admon.org admon.org;

        root /var/www/admonsites;
        access_log www.admon-access.log;

        error_log www.admon-error.log;
        index index.php;

	if (!-e $request_filename) {
		rewrite /wp-admin$ $scheme://$host$uri/ permanent;
		rewrite ^(/[^/]+)?(/wp-.*) $2 last;
		rewrite ^(/[^/]+)?(/.*\.php) $2 last;
	}

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

	location ~ \.php$ {
		try_files $uri /index.php;
		include fastcgi_params;
		fastcgi_pass unix:/var/run/php-fastcgi/php-fastcgi.socket;
	}

	location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
		access_log off;	log_not_found off; expires max;
	}

	location = /robots.txt { access_log off; log_not_found off; }
	location ~ /\. { deny  all; access_log off; log_not_found off; }
}

Some notes,

  1. The directory “/var/www/admonsites” is the place where WordPress Multi site installed.
  2. Wildcard subdomains should be enabled.
Share Button

Leave a comment

Your email address will not be published. Required fields are marked *