I had to setup another WordPress Multisite instance this week, so I thought I’d track my process this time – so I can share the experience. Please note that while much of this is platform independent, some of the steps are specific to Linux (and more specifically, CentOS).
I’ll also be merging my steps with the “official” steps from wordpress.org, to be sure nothing is left out.
The backup
Backing up your existing site database and files is not only simple, but essential. There’s no way for any product or add-on to account for every possible situation that might cause your site to break, so this is a very good idea.
cd /var/www/html/ tar -cf mysite.tar mysite_com/ mysqldump -u username -ppassword mysite_com > mysite_com.sql mv mysite_com.sql mysite.tar /home/myhomedirectory
Ensure that Pretty Permalinks is enabled
If your blog links are already SEO friendly (they don’t look like this http://www.mysite.com/?p=40), you can skip this step.
If they do have that ugly little ?p in them, you need to do two things:
- If your site’s root directory doesn’t have an .htaccess file in it, create one. Then add the following:
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>
- Go to Settings → Permalinks, choose the “Post Name” option, then save.
Deactivate All Plugins
This isn’t as bad as it sounds. This action won’t actually remove the data created by these plugins, but rather simply remove all of the “hooks” that they have into the WordPress core. You’ll reactivate them without issue once the Multi-Site setup is complete.
Plugins → Check All Button → Bulk Actions (Deactivate) → Apply
Enabling Multi-Site
- Open up your /config.php file.
- Find the line that starts with
/** Absolute path to the WordPress directory. */ - Place this code above that line
define( 'WP_ALLOW_MULTISITE', true );
Let’s get our Multisite Network Going!
- Refresh the page.
- You’ll likely be kicked out of WordPress (this is normal), so log in again.
- Visit the new Tools → Network Setup option.
The next step is to choose between the Sub-domain or Sub-directory options. This is more a business logic decision than a technical one. If you are creating individual blogs for each department within the same company, it probably makes more sense to use the sub-directory option so you can share SEO juice.
Once you’ve chosen an option, it’s just a matter of following the on-screen instructions. The one thing to take special note of is that you will be replacing the existing Rewrite rules in your .htaccess file, not appending to them.
That’s it. Refresh the page, and you’ll be required to log in again. Oh, and don’t forget to reactivate those plugins!
Reactivating Plugins
- My Sites (at the top) → Network Admin → Plugins → Check All → Bulk Actions (Network Activate)
Beyond Setup
So, what now? What you do from here is entirely dependent on the reason you setup Multisite in the first place. In my case, I did it for a client who runs completely revises their website on an annual basis, but it’s essential that they keep copies of previous years accessible.
Setting up an Annually Archived Site
I thought WordPress Multisite the perfect fit for this scenario, as we can archive the entire website within a subdirectory (New Site) at the beginning of each year. Then, simply change the content on the “Primary Site”.
A different theme from the “Primary Site”
In my case, much of the content that requires changing is within the theme files themselves. So, the quickest option for me was to duplicate the custom theme we created for the site and call it xxxxCurrentYear.
- The first thing you’ll notice is that any new site you create will automatically default back to WordPress’s default theme. This is okay.
- Copying a theme is as simple as doing a copy command at the command line, or using your favorite IDE to simply copy/paste the theme folder within /themes.
- Once you’ve done that, open up the style.css file within your copied theme.
- Change the Theme Name to xxx CurrentYear.
- You may be tempted to change the Template to your existing custom theme, but I’d advise to leave it alone. If you change it, any changes you make to your existing theme will shine through to your “archived” theme.
- You might get frustrated at the fact that your new theme does not show up in the theme options. This is because it needs to be “Network Enabled” before it can be added to any of the individual sites.Go to My Site → Network → Themes, then enable your new copied theme.
- Now you can go to your new site within the “My Sites” menu, visit themes, and apply your new copied theme.
Copying Content to the Archived Sites
Since our process for archiving annually involves simply duplicating the site, then changing the content, we need a way to quickly move all content over to the archived site.
The built-in WordPress Export/Import feature takes care of this pretty gracefully for us.
- Tools → Export → Download Export File
- Click WordPress at the bottom
- Install import plugin
- Network Activate
- Visit your new site via My Sites → your new site
- Tools → Import → WordPress
- Browse for the file you exported in step 1.
- Upload File and Import
I’ve had this process fail before. And actually could not get it to work for me this time as well.
If it doesn’t work for you, I’ve actually found this WordPress plugin to do an excellent job of copying an entire site and creating a duplicate of it within a WordPress Network:
http://wordpress.org/plugins/ns-cloner-site-copier/installation/