Set up WordPress Multi-Site with Cloud Sites


WordPress MultiSite, which prior to version 3.0 of WordPress was known as WordPress MultiUser (WPMU), enables you to manage multiple WordPress sites from a single networked WordPress control panel. All of these sites use the same database, themes, plugins and file structure to keep everything localized to a single installation. You can deploy sites quickly with the same plug-ins, themes, and template as other sites. As a result, sites are easier to manage and you have more control over site content.

This article explains how to set up WordPress MultiSite by leveraging Cloud Sites and Cloud Databases.

Note: For scalability reasons, this article assumes the use of a Cloud Databases instance to better manage the connections. Database instances range in price, but the recommended starting memory size is 1 GB.

The process is divided into the following three main steps:

I. Set up a Cloud Databases instance and install WordPress

II. Configure WordPress

III. Add sites to the WordPress network

I. Set up a Cloud Databases instance and install WordPress

Set up a Cloud Databases instance

Set up a Cloud Databases instance that meets the following criteria: 

  • Located in the same data center as the Cloud Sites account
  • 1 GB of memory (which can later be increased if needed)

The disk space depends on the size of the database, taking into account that it may grow over time. For more information about setting up a Cloud Databases instance,review the following articles:

Install WordPress

Install WordPress on your Cloud Site. This site is the primary domain you will be hosting on WordPres MultiSite, and will serve as the Network Admin and main page. For more information on adding a site to your Cloud Sites control panel and installing WordPress, see the following articles:

While running the WordPress Setup wizard, configure the database connection details page with information about your Cloud Databases instance.
Note: For this specific installation, we do not recommend the use of the one-click installer.

wp-db-configuration-screen

II. Configure WordPress

Adjust the WordPress address URL

In the WordPress Administration console, go to Settings and change the WordPress Address (URL) value to use http://yourDomain. Remove the www from the URL if it's not already set this way. For example: http://example.com.

 

Allow WordPress MultiSite in wp-config.php

In the root install-directory, add the following line to the wp-config.php file above the line: /* That's all, stop editing! Happy blogging. */.

define( 'WP_ALLOW_MULTISITE', true );

Set up the MultiSite Network

  1. Go to the admin area and click the Tools menu. Then click Network Setup


    Note:
    If you are unable to see the Network Setup option, make sure that the wp-config.php file has been set to allow WP MULTISITE, as described in the previous step.

  2. On the Network Setup screen, you will perform the following:

    1. Select the Subdomains Sub-directories for the Addresses of Sites in your Network value if you plan on using Domain Mapping for multiple URLs. This will make managing them easier.
    2. Enter values for the Network Title and Network Admin Email address, and then click Install.

Establish the network

  1. In your wp-config.php file in /PATH/TO/YOUR/SITE/web/content, add the following  lines above the line /* That's all, stop editing! Happy blogging. */:

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

  2. Add the following to your .htaccess file in /mnt/stor3-wc2-dfw1/506918/www.wpmumainsite.com/web/content/ , replacing other WordPress rules:
    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)$ wp/$1 [L]
    RewriteRule . index.php [L]

    Note: If you do not have an .htaccess file, simply create a file called .htaccess using an FTP client, such as Filezilla. For more information about .htaccess file, see Rackspace Cloud Essentials 5 - Tips and Tricks for .htaccess and web.config.

  3. Add the following block of rules to your .htaccess file as well to force the pages to all redirect to non-www versions of the domain:
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
  4. Log out of the WordPress Administration console, and then log back in.

Note: Because of the way Cloud Sites works, each site that you need to have managed by the main MultiSite installation must be created as an alias. The aliased domain, added through the Cloud Sites Control Panel, must have the primary MultiSite domain as its target.  For more information about how to add an alias, see Getting Started With Cloud Sites - Creating Sub-domains and/or Domain Aliases.

Continue to the next section if you would like to map full domains to your multisite entries rather than use subdomains or subfolders in the URL.

Install the WordPress MU Domain Mapping plugin

After you log back in to the WordPress Administration console, install the WordPress MU Domain Mapping plugin, as follows:

  1. Go to My Sites > Network Admin > Plugins.

  2. Click on the Add New button.

  3. Search for WordPress MU Domain Mapping.

  4. Click Install Now.

  5. Activate the plug-in by clicking Network Activate.

Configure Domain Mapping plug-in

  1. Copy the ../wp-content/plugins/wordpress-mu-domain-mapping/sunrise.php file to the wp-content/ folder.

  2. In the wp-config.php file, above the /* That's all, stop editing! Happy blogging. */  line, insert the following:
    define( 'SUNRISE', 'on' );
  3. In the WordPress Administration console, click Settings > Domain Mapping.
  4. Set the Server IP Address to the current site's IP address.
    Note: You can find the site's IP address in the Cloud Sites Control Panel, on the General Settings tab or the DNS tab (for SSL-enabled sites).
  5. Under Domain Options, select check boxes 2 and 3 only (make sure the others are unchecked), and then click Save.

 

III. Add sites to the WordPress network

The final step in this process is to add sites to your WordPress network. To do so, perform the following steps:

  1. In the WordPress Administration console, click My Sites > Network Admin > Sites.
  2. Click Add New.

  3. Enter the information for the site you want to add to the network.

  4. Click Add Site.

  5. Go back to the Sites list by clicking on Sites > All Sites in the left navigation pane.

  6. From the list, click on the site you just added, which will open the Edit Site page.
    Note: In the address bar, you should see a URL that looks similar to http://wpmumainsite.com/wp-admin/network/site-info.php?id=2.

  7. Note the number that follows after ?id=. This is the site's ID number, and you will need it in the next steps.

  8. In the navigation pane, click on Settings > Domains.

  9. Under New Domain, enter the number you obtained from the URL in the Site ID field.

  10. Clear the Primary check box.

  11. Click Save.
    Note: It is necessary to use the domain without the www. If you are using a subdomain, use only the subdomain (for example, subdomain.domain.com).

Repeat the steps from this section for any other sites that you want to add to the WordPress MultiSite network. Don't forget to add your alias! You can make adjustments, such as using www instead of non-www. This change, however, will require a different URL rewrite in the .htaccess file to force to www versions, which will then cause any subdomains to not map correctly because using www with subdomains does not work in Cloud Sites.



Was this content helpful?




© 2014 Rackspace US, Inc.

Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License


See license specifics and DISCLAIMER