Wordpress Multi-Site Converting Apache to Nginx

nrahl nginx-forum at nginx.us
Thu May 1 07:02:01 UTC 2014


> With wordpress MU setups, you need to manually set up the blog id
> ( well, at least I have so far )... here's some extracts from one of
> my
> site configs:
> 
> location ^~ /blogs.dir {

Thanks for sharing your config.

What version of WordPress are you running? Mine doesn't have a blogs.dir
directory. I think they did away with that in 3.5. My WPMU setup was working
fine without that dir on Apache, so it must not be needed in my version.

> If that still doesn't work, can you check that you've got everything
> connected correctly by delivering a quick <?php phpinfo(); ?> file to
> your browser?

I can make PHP scripts run when I disable the wordpress location blocks and
use my CMS's location blocks. The PHP scripts run fine, so PHP and PHP-FPM
are running OK.

> There are example configs on the net - wordpress offers one for
> certain, and googling for wordpress, mu and nginx deliver a plethora of
howtos.
> Why not begin with one of them and try to understand it, rather than
> fighting to reinvent the wheel?
> 

I actually did quite a lot of reading before posting here. There are several
reasons the configs out there don't work.

1. WordPress Multi-Site got a major overhaul in 3.5 and the tutorials out
there, including Wordpress's own site are for the old version. I'm running
3.9, which uses the new 3.5+ way of detecting blogs.

2. My CMS uses /*/ and /*/*/ (where star is any URL char) type rules to grab
everything that isn't otherwise defined explicitly, and this is creating
problems with any smart wordpress configs. In order for this to work, I need
to hard-code the wordpress blog URLs at a higher priority than the patterns.
ie. if /myblog/ or /otherblog/ pass to wordpress, if /*AnythingElse*/ pass
to CMS.

3. The CMS, not the wordpress master blog, is at the site root.

4. The actual wordpress files live in a folder /wordpress/ which is not
meant to be accessed directly. wordpress expects the blogs to be in
subdirectories, such as /wordpress/someblog/, but really, we want them to
appear off the root like /someblog/ so we have to trick wordpress using
rewrite rules.

This entire configuration was 100% functional using Apache2. I'm assuming
that Nginx can emulate any behaviour Apache can, but maybe there's some
configs that it can't support?

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,249743,249783#msg-249783



More information about the nginx mailing list