Setting Up WordPress Multisite

Posted on: November 20th, 2013

For a recent project I needed to set up WordPress Multisite and had never done it before. The following is my process and the things I learned while working to get the network up and running.

Also, if you came here because of the excerpt, I know Facebook was not built on WordPress Multisite, everyone knows it was a BuddyPress installation.

The Codex

First thing is first, what did the Codex have to say about WordPress Multisite installations? Pretty much before starting, you should have a pretty good idea of how multisite actually runs. What are you going to do with new sites (domain-based or path-based) and a few other odds and ends. I dove in and started off strong.

The Installation

The installation aspect is pretty easy, just add a line to wp-config.php and go about business as usual. Once your install is complete, go to Dashboard -> Tools -> Network Setup. There will be a shiny Install button to click, so click it. A few things might happen after that. If you’re like me, you’ll be told that “the wildcard subdomain test failed an you should stop using the internets because you’re terrible at it.” So it’s not that specific, but it was correct about the Wildcard record for subdomains. I was hosting my site on Web Faction with the domain at Namecheap.com.

The Wildcard

I originally had the DNS pointing from Namecheap to Web Faction’s nameservers as I was so oft to do, but that was a mistake. Unfortunately (that I found at least) you can’t actually create a wildcard record on Web Faction, so I transferred the DNS back to Namecheap where I was able to easily add a wildcard and add in the Web Faction IP address where my site was hosted. Everything was hooked up so I returned to my install to install again. Problem was, the tables had already been created so I wasn’t sure if it was going to work properly.

The Tables

If you have access to your database, it’s a good idea to become familiar with the WordPress structure, or any database structure for that matter. I wasn’t sure what tables were added, so I headed back to the forums. Thankfully @andrea_r had the answer.

wp_blogs
wp_blog_versions
wp_registration_log
wp_signups
wp_site
wp_sitemeta

Those were the tables standing between me and the assurance that my network would run fine, so I deleted them. The standard WordPress install has 11 tables, Multisite adds 6. After deleting I headed back to Network Setup which had now reset properly. I again was prompted to Install, but first I checked on my htaccess file (Note: if you haven’t touched your permalinks, you may not have an .htaccess file yet). mod_rewrite was installed so everything looked good to go.

I couldn’t figure it out so I said screw it and plowed ahead.

wp-config

Back to the config file, once you’ve set up the network you’ll need to add this chunk of code right under where you added the portion about MULTISITE:

define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', true);
define('DOMAIN_CURRENT_SITE', 'movembermadness.com');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

and then add to .htaccess:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]

overriding anything you previously had in there. Log back into your site and BLAM-O, you’re done.

Adding a New Site

If you’ve read this whole post, you know I gave up with the wildcard DNS record, mainly because it was 12:30am so support for Namecheap and Web Faction were not awake. I installed the new site with success, in that the Network Admin dashboard told me it was successful. I tried to visit the new site dashboard at subdomain.example.com, but was hit with a “Site not configured” message.

I added the sub-domain to my records list in Namecheap to see if that would help. Meanwhile I also added in a catch-all wildcard record, hopefully the way multisite wanted me to.

Those didn’t work BUT, when I added the subdomain to my Web Faction websites list, it showed up correctly. So there is a bit of manual labor involved at this point (which I’d like to get rid of) but for now it’s good to go.

Conclusion

Overall Multisite is a really cool thing. I haven’t tapped into all of its power yet, but plan on setting it up for this domain once I get around to re-doing my theme.

What experiences have you had with Multisite? Good or bad, tell me your tale in the comments below!

Tags:

previous post: Finding Free Music For Projects next post: Responsive Squares Without Flexbox