[http://wordpressthemes.eu.com/ Wordpress] Multisite require permalinks and redirection to existing PHP files, thus we have to remove the blog name from the URLs.

+

[http://codex.wordpress.org/Create_A_Network WordPress Multisite] requires permalinks and redirection to existing PHP files, thus we have to remove the blog name from the URLs.

<geshi lang="nginx">

<geshi lang="nginx">

Revision as of 07:06, 12 August 2012

Nginx works perfectly well with a wide variety of applications, and WordPress is certainly one of them. NginX's configuration language is very powerful and straightforward if one is familiar with it, but often people coming from other servers are not sure how things work in NginX and just copy and paste whatever they see from a blog that seems to fill their needs. Everyone, especially people new to NginX, should check out the nginx.org documentation for an overview of how things work and should be done in NginX.

Contents

Abridged basic setup

Hopefully you have read the documentation above and maybe worked on setting up a virtual server or two in Nginx already - if not there are a few notes below, but you should still read the documentation.

First we setup a named upstream for our php, which allows us to abstract the backend and easily change the port or add more backends. After that, we setup our virtual host configuration for domain.tld.

With this configuration we should be able to serve wordpress very easily. Once you setup your backend (php-cgi or php-fpm) should work perfectly.

Location Strategies

There are many ways to declare your locations in your configuration that allow you to do basically whatever you want with your URLs. Usually, people want to have "pretty" URLs that hide the query strings and script files. Here are a few different strategies based on different goals. Here we are defining locations that should be used to replace the basic locations above in order to achieve the desired results.

Non-root try_files to URL redirect

If you want to serve WordPress as a sub directory, you will want to make the following changes (relative to the above configuration).