In this tutorial, I will walk you through the installation of WordPress Multisite and explain how to configure it so that you can run multiple domains from the same WordPress installation.
Why Use WordPress MultiSite?
Managing multiple sites from the same WordPress installation has a lot of nice advantages.
One of the basic advantages is that you won’t have to install the same plugins over and over again as you start new sites (this is especially helpful if you’re using plugins like Akismet or Gravity Forms where you always have to hunt for your license/API keys). Now, you can just network enable your plugins and use them on any site you want to. You also won’t have to upgrade multiple WordPress installations whenever a new version is released — a single click of the button will get all your sites completely up to date. And adding a new domain takes only a minute.
There are many advanced possibilities as well. If you’re a developer, you’re probably familiar with the pains of maintaining multiple code bases, or upgrading multiple instances of the same theme thanks to the hell that is cross-site PHP scripting. Well, you can kiss those pains goodbye now. We’ll be setting up virtual sites here, so you’ll be able to access the same files/themes/plugins/whatever you want from any site on your WordPress installation — this is powerful stuff.
This is a relatively advanced tutorial as far as most WordPress tutorials go. You don’t have to do any programming, but you will have to make some edits to files that will completely crash your site if you make a mistake. A basic understanding of htaccess and php is recommended.
- Your existing WordPress installation *must* be in the root of your site (not a subdirectory like /blog ).
- You must have access to a control panel like cPanel or Plesk.
- Your host must allow the creation of subdomains.
Before You Begin
At this point, it’s a good idea to go ahead and set your DNS settings on the sub-sites that you want to work with (ie: you want to add mysite2.com to the mysite1.com installation). This should ensure that the DNS propagation will be complete by the time you complete this tutorial.
The nameservers on your ‘secondary’ sites should match those of the root domain (mysite1.com) that we’ll be working with here.
Installing WordPress Multisite
One of the nice things about post 3.0 WordPress is that MultiSite is prepackaged, just waiting for you to enable it — much like a War of the Worlds invasion.
To enable WordPress Multisite, open your wp-config.php file and add the following line directly above where it says /*That’s all, stop editing! Happy blogging */
There are two primary options that you need to be aware of when configuring MultiSite:
- Your sites can be in subfolders ( /blog/) or
- Subdomains ( blog.yoursite.com )
If you want to run multiple domains on the same installation, you’ll need to use subdomains. To ensure that all new sites you create are setup as subdomains, add this line to wp-config.php as well, directly below the command above.
[php]define( ‘SUBDOMAIN_INSTALL’, true );[/php]
Create a New Directory
Before you can enable your network of sites, you will need to create a directory named blogs.dir inside your /wp-content/ directory. This is the directory that will be home to all of your uploaded media files (images, etc). Make sure that the blogs.dir directory has the same permissions as your /wp-content/ directory (most likely 755).
Enable Your Network
Now that you’ve created the blogs.dir directory, you need to enable your network of sites in WordPress. To do so, login to WordPress and click the Network Setup link on the left hand nav:
Note: You will have to temporarily deactivate your plugins to successfully enable the network. Don’t worry, it will only take a minute.
Once you’ve deactivated your plugins, enter your Network Title and email address into the form and click the Install button.
You will now be presented with either two or three text boxes filled with code (depending on your original wp-config setup). These are simple copy+paste jobs.
Follow the instructions preceding each text box — you will be editing your wp-config.php and .htaccess files. Be very careful, and make a backup of each file before editing: making a mistake in either of these files will completely crash your site.
When you finish making the changes and verify that your site is still running, you will need to logout and back into WordPress.
When you log back in, you’ll need to make sure that you’re in the Network Admin and not Site Admin. To switch to Network Admin, mouse over your username at the top right of your WordPress admin UI, and you’ll see something like this:
Select Network Admin from the list, and then go ahead and reactivate your plugins (Network Enable any plugins that you want to use on multiple sites).
Enable Wildcard Subdomains
Before you can create new subdomain sites that actually work, you’ll need to enable wildcard subdomains. If you’re using cPanel, you can enable your subdomains by navigating to your site’s control panel (click List Accounts on the left nav, and then the cPanel icon next to the site you want to add the subdomain to) and adding a new subdomain. To add a wildcard subdomain, put a * in the subdomain field as pictured below.
Also, make sure that you set the value of the Document Root field to the root level of your WordPress install (which should be the root of your site).
If you’re using Plesk, follow these instructions.
Install WordPress MU Domain Mapping Plugin
Once it’s installed, you will need to make some manual adjustments.
1. In your FTP client, navigate to the WordPress MU Domain Mapping directory. Download sunrise.php to your desktop, and re-upload into /wp-content/. If you already have a sunrise.php file (you probably won’t), you will need to merge the two.
2. Edit wp-config.php and add this line above the last “require_once” command:
define( ‘SUNRISE’, ‘on’ );
Set WordPress MU Domain Mapping Options
In WordPress (still in Network Admin), go to Settings->Domain Mapping.
On the following screen, you will presented with the options below. I have found that the following settings work well for my needs:
Adding a New Domain To Your Network
In WordPress, go to Sites->Add New
Enter the subdomain for this site, your site’s title, and your email address. Here’s how I set mine up:
When finished, click the Add Site button.
Now go to Sites->All Sites. Mouse over the new subdomain you just created, and watch the tooltip at the bottom of your browser to see the destination URL. You’ll see a URL parameter called ‘id.’ This parameter stores that site’s unique numerical ID. Write it down — you’ll need it in a second.
Now we’re ready to configure the domain mapping in the WordPress MU Domain Mapping Plugin.
Configure Domain Mapping
In WordPress, click ‘Domains’ from the Settings section of the left nav. When the page loads, focus your attention on the ‘New Domain’ section of the page. Here, there are two fields. One is the site’s ID (the unique number you wrote down a second ago) and the domain. Basically, you are telling the plugin that the subdomain behind Site ID x should resolve to the domain you’re putting in the Domain box.
Here are my settings:
Once you have things the way you want them, click the Save button.
Park Your Domain
This is the last step (woot). Here, we’re going to park your secondary domain (mynewsite.com) on top of your primary domain (in my case, makeitrank.com).
If you’re using cPanel, navigate to DNS Functions -> Park a Domain.
Here, we’re parking the new domain on top of the ‘root’ domain we’re already running WordPress on.
(I scratched out my username in the screenshot above because…well…it wouldn’t be secure to show you that, would it?)
Click the ‘Submit’ button, and check on your site. Your new domain should be running perfectly.
From here on out, when you want to create a new site all you have to do is:
- Add a new site within WordPress
- Set the DNS on your new site to match the settings on the ‘root’ site
- Configure the site in the Domain Mapping plugin
- Park the new domain on top of the ‘root’ domain
I hope you found this useful. If you have any questions/comments, leave them in the comments below.