wiki:how-to/wordpress/network

Version 3 (modified by Jesus Franco, 11 years ago) ( diff )

adding tag for spanish translation

TranslatedPages

How to create a WordPress network handling multiple domains

Draft. These instructions are roughly equivalent to a live multisite in bluehost, supporting 5 domains, everyone with at least two subdomains, making a total of 27 blogs running every one their contents and users/roles, also every one being able to chose apart of every other blog among a selection of themes and plugins, but sharing a common codebase easier to handle and upgrade, with some security and performance plugins enforced for all the blogs without the admins of every site being able to disable the network settings. This is proposed as a help to ticket:7682 and similar cases, but is has not being tested in MF/PL account with several domains, but only subdomains. Also, these are only the first steps to run a network and not a whole specification on security and performance matching the resources available to MF/PL members, since these are better than resources typically available to stock commercial shared hosting from which this experience comes.

How to create a WP multiblogs network

Prerequisites

  1. Domains pointing to MF/PL nameservers.
  2. Admin access, and SFTP access to editing wp-config and .htaccess
  3. Permalinks (clean URLs) working properly.

Domain mapping to MF/PL nameservers

Add New Domain to existing account.

Wildcard subdomain for WP network

This is not estrictly necessary, but it would help you a lot if your need to set up quickly a new subdomain inside your WP Network after it is properly configured.

Once you have set up your domain(s) to point to MF/PL nameservers, through your domain registrar panel and the MF/PL control panel, you should add another record into the DNS area of your account:

  • Record Type: A
  • Server Address: same IP of your domain.
  • Domain: *.yourexampledomain.net

Web Configuration to attach the domains to the WP network

  1. Inside your MF/PL control panel, go to the Web Configuration tab.
  2. Locate the record your site should be launched.
  3. Add to the ServerAlias, two entries: yourdomain (just in case you have not already added it through the Domain Mapping linked above) and the wildcard subdomain.
  4. Hit Submit and give it a minute to go active.

The ServerAlias column should look like this:
myuser.mayfirst.org example.com *.example.com

WP install and permalinks configuration

This is fairly basic stuff and if you are reading this you have probably managed the very easy installation of WP before. Just make sure your permalinks are working according to your needs on Settings -> Permalinks.

Tip: If you are running your site already with www url (www.example.com), you should temporarily convert it to example.com, in order to making easier to create the network of blogs in the first subdomains for your domains. Subdomain1.example.com, subdomain2.example are pretty easier to handle tha subdomain1.www.example.com... Once you have setup your network without www, you can go back to www.example.com since it helps a slighlty better performance.

Creating the Network

The procedure is well known and documented in the WordPress' Codex. This is a quick outline of the steps involved:

  1. Add to wp-config.php above /*That's all, stop editing*/ line, the next definition:
    define( 'WP_ALLOW_MULTISITE', true );

  2. Refresh or enter into your admin area, and go to Tools -> Network Setup.

  3. Choose subdomains install, and fullfill at least the next values: Server Address (remember, is easier without www.), Network Title (in example, for Radio Zapote, the Network is Rizoma Zapote), Admin E-mail Address (this email is going to receive notices of new blogs and user accounts created through the whole network).

  4. Get the code given to you by the wizard and place them accordingly:
    • New definitions, should be added to wp-config.php after ALLOW MULTISITE you inserted, and before /*...Stop editing...*/ comment.

    • New .htaccess directives should replace the previously created by WP on Permalinks setup. In contrast to Permalinks setup, WP is not going to add this rules to .htaccess by itslef, this is why you should have SFTP access to create the network.

  5. Re-login, if you are redirected, clean your cookies.

  6. Go to your Network Admin area and in the sites listing (http://example.com/wp-admin/network/sites/) and click the Add New item. You can now create new subdomains/blogs each one with their own admins, choosing among the themes you have installed on the network (the blogs' admins are not able anymore to add/delete/upgrade themes/plugins, only SuperAdmins should).

So far, we can host several subdomains with the same WP codebase shared among all of them (core, themes, plugins, and you need only upgrade once the software and not to doing that over and over on every site). But to make the network able to handle several domains, the easier way is through a domain mapping plugin:

Mapping multiple domains to the same network

While you shouldn't to install a new WordPress application for every new domain, you should make sure you are adding the domains according to the prerequisites listed before, mapping your domain first to MF/PL nameservers, then adding the domain and its wildcard subdomain to the ServerAlias of the same Web Configuration your current WP Network.

There are two plugins available for this, the original one available in WP.org, WordPress MU Domain Mapping, helps you make every subdomain, a different domain, then you can have example2.com, example3.com and so on without maintaining a whole different WP install.

Another one, based on the first, is developed to let you handle several domains and their respective subdomains through the same network. For a real example, we run several blogs like resonancia.saltoscuanticos.org, rac.saltoscuanticos.org, tomalapalabra.radiozapote.org, subalterno.radiozapote.org, and of course www.saltoscuanticos.org and www.radiozapote.org, all handled by the same network and being easier to maintain and upgrade, supporting several projects more easily and enforcing security and performance rules when needed, not being able to blogs admins to disable the SuperAdmin installed tweaks.

While a bit different, the process to install these plugins it's not the typical one through search/upload, activate and go. We are going to detail the enabling of the second plugin, GPL'ed but upgradable only through a paid subscription to WPMUDEV:

  1. Download the plugin (attached) and uncompress it on your own workstation (not the webserver).
  1. Connect via SFTP to your account, and upload the different pieces of the plugin to the next wp-content locations:

    • sunrise.php -> wp-content/
    • dm_sunrise.php -> wp-content/plugins/
    • /mu-plugins/ -> wp-content/plugins/
  1. Edit again your wp-config.php and add the next definition:
    define('SUNRISE', on);
  1. Login to your Network admin area and "Network activate" the "Multi-Domains for Multisite" plugin.
    http://example.com/wp-admin/network/plugins.php
  1. Now you have the Multi-Domains item inside the Tools Menu in the Network Admin area. There you can add new domains to your network. You can enable a domain to be "private" (only other SuperAdmins can create new blogs for that domain, and assign new admin users to publish in them), or "public" (if you let existing/new users register by themselves new blogs, they will be able to choose that domain among all others domains marked as "public").

Beyond first Network

It's possible running several networks over the same codebase (WP core, themes, plugins), without the sunrise domain mapping plugins, but it involves a bit of work right into the wp_site and wp_sitemeta tables, as it's described here: http://webmasterformat.com/blog/multiple-wp-site-management While a bit more involved, the advantage is being able to define different sets of super-admins, themes and plugins enabled, for different networks/sites/domains. With the sunrise domain mapping plugins, all the blogs run on the same network which is easier to handle.

So, just for clarify, every site listed in wp_site table is a network and with the domain mapping plugins, can support several domains/subdomains (listed each one in wp_blogs table). Without any of these plugins, you can anyway support several domains/subdomains, but they will be handled logically like different networks. This can be very useful according to more complex userbases and projects.

A note about security

Be cautious on letting every single visitor to register a new account and creating new blogs, on the recents attack waves from botnets to WP sites across the world, we resisted because we didn't let anyone to register a new site, and we were hitted a lot! in the pages known to be entry point to spammers. Also, remember you are not letting every blog admin to install new plugins or new themes, not upgrading, nor editing them, their permissions are roughly similar (a bit more relaxed, actually), to the admins of wordpress.com or network23.org blogs.

Anyway, if you keep the upgrades of the sites running smoothly and pay attention to help provided by tools like Better WP Security, W3TotalCache and several others (this is a whole area to be expanded in other how-to's), you are going to have happier users, and be a happier admin too without the nightmare of upgrade every single site, but all your network at once. Even if you are the only SuperAdmin/Admin/Editor of your sites (or have a very small team), the time spent on setting up your network is not a loss but a win in sleep hours into the future.

Make Happy Networks! \o/

Attachments (1)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.