I’ve spent a good chunk of time this week transitioning AFdN from a standalone WordPress site to be part of the ferguson.pw WordPress Multisite cluster.
This is more cool for me than you because I now only have to manage one WordPress installation for everyone, rather than two or more installations. Huzzah!
Some lessons learned:
- Multisite cookies are the suck. Towards the end of the migration I ran into an issue where draft post previews were not working. I started running through my checklist of things that could be the cause, but nothing made sense. I eventually created a new user —
notandrew
— to see it was an issue limited my “super-administrator” capabilities and to my surprisenotandrew
could see the previews just fine. So I nuked all cookies for ferguson.pw domain and lo and behold everything worked. - When migrating a Standalone WordPress site to a Multisite and mapping the domain back to the original URL you can use the following Nginx rewrite to prevent breaking anything1:
#rewrite for WordPress single site to multisite location /wp-content/uploads/ { rewrite "^(/wp-content/uploads)/([0-9]{4}/[0-9]{2}/.*)" $1/sites/$blogid/$2; }
Note: this is also predicated on using the Nginx
Map{..}
directive. - There’s a long standing bug with Nginx regarding the use of
alias
versusroot
. In the end I was able to usealias
2 to host a special directory for TweetNest. Here’s the solution I ultimately arrived at:location /tweetnest { alias /path/to/example.com/html/tweetnest; rewrite ^/tweetnest/sort /tweetnest/sort.php; rewrite ^/tweetnest/favorites /tweetnest/favorites.php; rewrite ^/tweetnest/search /tweetnest/search.php; rewrite ^/tweetnest/([0-9]+)/([0-9]+)/([0-9]+)? /tweetnest/day.php?y=$1&m=$2&d=$3; rewrite ^/tweetnest/([0-9]+)/([0-9]+)? /tweetnest/month.php?y=$1&m=$2; location ~ \.php$ { fastcgi_split_path_info ^(.+?\.php)(/.*)?$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include /etc/nginx/fastcgi_params; } }
I also took the opportunity to clear out some cruft and update some look and feel stuff: redish/orangish theme, update profile, etc. Nothing should be broken, but you never know. Enjoy your weekend.
0
Hi Andrew, awesome blog. Lots of great info here. I was wondering if you could share your nginx map expression for a new wordpress multisite install. Old multisite installs had files in wp-content/blogs.dir/sitenumber/files , now they are located in wp-content/uploads/sites/sitenumber/year/month. I’m trying to figure out a regular expression that would work for this but I’m a bit lost.
The previous code worked out to
map $uri $blogname{
~^(?P/[^/]+/)files/(.*) $blogpath ;
}
I use a WordPress plugin, nginx Helper ( http://wordpress.org/extend/plugins/nginx-helper/), which was developed by the fine folks at rtCamp. They also have some excellent configuration guides: https://rtcamp.com/wordpress-nginx/tutorials/
Here’s a sanitized version of my particular configuration: https://gist.github.com/fergbrain/c2ca56dcecc82938dceb
Comments are closed.