WordPress is an amazing piece of software. One of its more advanced features is called multisite. With WordPress multisite, you can essentially build your own blog network, similar to Wordpress.com or Tumblr.
Multisite is an integrated part of the WordPress core. That means you won't have to download anything other than the official WordPress package to get set up. There are some basic system requirements that you should consider before even trying to install WordPress. At the most basic level, WordPress requires PHP 5.2.4 or greater and MySQL 5.0 or greater. You can see a detailed list of system requirements at http://wordpress.org/about/requirements/.
There are some basic things you should take into consideration before deciding to use WordPress multisite for your project. Most important is defining a project scope and making sure that WordPress provides enough features to meet that scope. It's possible that WordPress is overkill, in terms of features, for your project as well. It's all really dictated by the specific features your project needs.
Chances are, since you're reading this book, you want to set up a blog network of some type. WordPress multisite is used for a wide variety of reasons, from university class blogs to high-traffic websites or anything in between. The most common use of WordPress multisite I've seen is with small groups of individuals who want a blog but don't want to join a massive blog network such as WordPress.com.
WordPress didn't always include the multisite feature. Prior to WordPress 3.0, WordPress came in two flavors, regular and multiuser . WordPress 3.0 introduced WordPress multisite, as it's known today. WordPress 3.0 was released in June 17, 2010.
There are going to be some basic WordPress-related terms that you'll want to become familiar with. These terms usually apply to multisite and a standard WordPress single-site install. You can check some of the terminologies used in WordPress at http://codex.wordpress.org/WordPress_Semantics.
Now that you've got some basic WordPress knowledge, we might as well get to downloading and installing WordPress. The WordPress installation process is very easy, only requiring you to upload the files to your webhost and then to edit database connection settings in a file named wp-config.php
.
Before we get too far, we need to take a couple things into consideration. First, think about how you want URLs to be set up. You can use subdomains for each individual's blog URL or you can use a subfolder style setup, such as http://multisite.longren.org/tyler/. Also, installing themes and plugins is a bit different from a typical WordPress install, but we'll get to that a bit later in this chapter. I really suggest reading the Before You Create A Network article in the WordPress Codex, available at http://codex.wordpress.org/Before_You_Create_A_Network.
Okay, let's get down to installing WordPress and enabling the multisite feature.
We'll start the WordPress installation wizard with the web browser. I like to use Google Chrome but any web browser should work. So, open your browser and navigate to your multisite installation URL. I installed WordPress multisite at a subdomain of my main longren.org domain name, but you can use a subdirectory too, such as http://www.longren.org/multisite/.
Once you've opened your site you'll see a window as shown in the following screenshot. This is where you can set the name of the site as well as choose your administrative username and password. The default administrative username in WordPress is admin
but I highly suggest that you change that to something else. A lot of WordPress web attacks try to exploit the default administrative account name, so not having an admin
user puts you in a better position security-wise.

That is the only page where you need to enter any information in the WordPress installation wizard. In the next screenshot, you can see what the page in the previous screenshot should look like after you've filled everything out.
.

After you've filled everything out and chosen a username anything other than the admin
term, click on the Install WordPress button at the bottom of that page. After clicking on Install WordPress, you'll see a Success
!
message along with your chosen username. As you can see in the following screenshot, your password isn't shown on the screen:

Once you're on the Success! page, you can click on the Log In button. You'll be taken to your WordPress login page, located at /wp-login.php
or http://multisite.longren.org/wp-login.php in my example. You can also navigate to /wp-admin/
or http://multisite.longren.org/wp-ad min/, to log in to your WordPress Dashboard window. The default login page can be seen in the following screenshot. The login screen can be changed visually through the use of plugins or custom settings for your WordPress theme.

Enter the Username and Password values that you chose when going through the WordPress installation wizard to get logged in. Upon successful login, you'll be taken to your WordPress Dashboard window for the first time. Now, we get to do more stuff that's specific to multisite setups. But first, the following screenshot shows what your WordPress Dashboard window should look like:

First, we need to download WordPress. Open your web browser and navigate to http://wordpress.org/download/. At that page you can choose to download WordPress as a ZIP file or as a .tar.gz
file. If you're on Windows you'll probably want to download the ZIP file, while Linux and OS X users can download whichever they prefer.
Once you've got the .zip
or .tar.gz
file downloaded, open it up and you should see a folder named wordpress
in there. Extract that wordpress
folder to somewhere on your local computer, such as your desktop. Next, open up an FTP connection to your webhost and upload everything from the wordpress
directory that we have put on your desktop earlier.
After the upload is finished, go ahead and install WordPress as you would for a single site. After that install is done, we'll edit wp-config.php
to enable multisite.
We'll go through the basic settings in wp-config.php
, including code snippets.
After renaming wp-config-sample.php
to wp-config.php
, open it up for editing. You can open it directly from your webhost if you're using a FTP client such as FileZilla. Just right-click on wp-config.php
and select View/Edit within FileZilla. I chose to use FileZilla as an example because it's available for multiple operating systems, including Windows, OS X, and Linux.
Once you've opened wp-config.php
in your text editor, you'll be presented with some code that looks like what you'll see in the next code.
// ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define('DB_NAME', 'database_name_here'); /** MySQL database username */ define('DB_USER', 'username_here'); /** MySQL database password */ define('DB_PASSWORD', 'password_here'); /** MySQL hostname */ define('DB_HOST', 'localhost'); /** Database Charset to use in creating database tables. */ define('DB_CHARSET', 'utf8'); /** The Database Collate type. Don't change this if in doubt. */ define('DB_COLLATE', ''); /* Multisite */ define('WP_ALLOW_MULTISITE', true); /**#@+ * Authentication Unique Keys and Salts. * * Change these to different unique phrases! * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service} * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again. * * @since 2.6.0 */ define('AUTH_KEY', 'put your unique phrase here'); define('SECURE_AUTH_KEY', 'put your unique phrase here'); define('LOGGED_IN_KEY', 'put your unique phrase here'); define('NONCE_KEY', 'put your unique phrase here'); define('AUTH_SALT', 'put your unique phrase here'); define('SECURE_AUTH_SALT', 'put your unique phrase here'); define('LOGGED_IN_SALT', 'put your unique phrase here'); define('NONCE_SALT', 'put your unique phrase here');
You may notice that there's an additional piece of code in there, compared to what's being shown in your wp-config.php
file. There's a comment in there that says Multisite
and directly under it is where we define the named constant, WP_ALLOW_MULTISITE
, to true
. In the following code, you'll find exactly what you need to add to wp-config.php
to enable the multisite feature:
/* Multisite */ define('WP_ALLOW_MULTISITE', true);
I like to set that constant below the database config settings, around lines 36 and 37 in the default wp-config.php
file.
The database configuration constants at the top of wp-config.php
are pretty self-explanatory. They're named things such as DB_NAME
, DB_USER
, and DB_PASSWORD
. Bet you can guess what those values should be set to. There are some not quite so obvious database settings too, such as DB_CHARSET
and DB_COLLATE
. It's usually a good idea to keep those at the default value; DB_CHARSET
is set to utf8
by default, which is Unicode. The DB_COLLATE
constant should contain a value for the language you're going to use within WordPress. If you're using English, you can just leave the value for DB_COLLATE
blank.
In the following code, I also included a bunch of named constants for authentication unique keys and salts, towards the bottom. You need to change the existing values there. You can easily generate new, random values by visiting https://api.wordpress.org/secret-key/1.1/salt/. Just copy the eight lines of code generated on that page and then paste it into wp-config.php
, replacing the other keys. So you should go from the following code to something resembling what you see in the version generated by api.wordpress.com:
define('AUTH_KEY', 'put your unique phrase here'); define('SECURE_AUTH_KEY', 'put your unique phrase here'); define('LOGGED_IN_KEY', 'put your unique phrase here'); define('NONCE_KEY', 'put your unique phrase here'); define('AUTH_SALT', 'put your unique phrase here'); define('SECURE_AUTH_SALT', 'put your unique phrase here'); define('LOGGED_IN_SALT', 'put your unique phrase here'); define('NONCE_SALT', 'put your unique phrase here');
And following is the code that's an example of the keys generated on the api.wordpress.com page:
define('AUTH_KEY', '*`b7,!cuc2Ub+IabKJ-h|*5SdfO8uBm-L1&=<Q5>6oiS3?qCTVA|^d%W(o[<Y-<C'); define('SECURE_AUTH_KEY', '<v?OP<V*:Nz#AazY0l?*7^{d-i6-EyA*,|Flp>|BR&*u=&Gad{2r6L^8g+#r~Z&^'); define('LOGGED_IN_KEY', 'I!u|T-h(4kc[ L%#QJs7`NyM.]]-W`/,rmhRteNQ`^LC+0>0&zG|6Lqe5Zf%kx$B'); define('NONCE_KEY', ',[RGlO?&-GDw|>DC&rH5gMQ040(d3Xo{dCAY~F28M=:=]l>/_,|d#l9X_aRTHfnp'); define('AUTH_SALT', '8G+g,K.Sd^PDyD,q@,mcXs&CxqR5veL*z9P%<O|+O2^YU}Ob^je|Ty;{JL1AQOz/'); define('SECURE_AUTH_SALT', 'mndP#V.PZNH+N2HN9,I5`KC_;|j7TyT[`_1UFX 3j|x18*cZSO5`u2j5miB^~d^:'); define('LOGGED_IN_SALT', '[>uO+hz%+0t9X1tf<P*Sx1q44leN_WI4$l>yD-fiu7a>{Gq+ubtqjpym4[S0YPTp'); define('NONCE_SALT', 'O -Gk@XjD{4PAi-*Q+OhVD^+6@C]Uebrwc}qLW,2tR*1g4+NMF(sbrp>ppoFD [j');
After making those changes to wp-config.php
, save the file and upload it back to your server. If you opened wp-config.php
directly with FileZilla, you'll be prompted with a window inside FileZilla that's titled File has changed. This window asks if you want to upload the changed file back to the server. Click on Yes and your modified wp-config.php
file will be automatically uploaded to its original location on your server. Any additional changes you make to wp-config.php
can be uploaded simply by saving wp-config.php
again and telling FileZilla to upload your changed file.
Now that our wp-config.php
file knows that we're going to set up multisite, it's time to run the network setup. To install a network, start out by putting your mouse cursor over the Tools menu on the left-hand side of the WordPress Dashboard window and clicking on the Network Setup submenu item.
The page you're taken to after clicking on the Network Setup submenu item is titled Create a Network of WordPress Sites. Sounds awesome, right? This is ultimately what we're here for, after all.
From here, you can specify if you want to use a subdomain for individual sites or if you'd rather use a directory. I've chosen to use a directory as I think that's the most common setup. So, the URLs in my example will be http://multisite.longren.org/tyler/ for my blog, http://multisite.longren.org/kayla/ for my wife, Kayla's, and http://multisite.longren.org/sydney/ for my daughter, Sydney's.
The setup I'm using on the Create a Network of WordPress Sites page can be seen in the following screenshot:

Specify your Network Title and Admin E-mail Address values and click on the Install button at the bottom of the form. After clicking on Install you'll see a page with Enabling the Network in bold at the top, with some more named constants being defined also. Copy and paste the code from the section 1 into your wp-config.php
file and re-upload it to your server. Next, edit your .htaccess
file. It should be in the same folder as wp-config.php
. If the .htaccess
file doesn't exist, you can save a blank text file as .htaccess
and upload it to your server. Copy the Apache rewrite rules from the section 2 into your .htaccess
file and upload it to your server, again, in the same directory as the wp-config.php
file.
The following screenshot shows the page after clicking on Install; it's the page that provides the sections 1 and 2, that I previously referenced:

After you've uploaded your modified wp-config.php
and .htaccess
files, the setup of your multisite network is complete. You'll need to log in again, so just click on the Log In link at the very end of the Enabling the Network page. You'll be taken to the login page as shown previously. You may need to clear the cache in your browser and possibly delete cookies for the domain your WordPress site is using.
After you're logged back in, you should see a My Sites link in the WordPress toolbar at the top-left corner of the screen. Put your mouse cursor over it and then click on the Network Admin item. Doing so will take you to the network Dashboard window, which is similar in appearance to the regular WordPress Dashboard window but significantly different in content. This is where you can see the sites hosted by your new network. From here, you can add new sites, new users, or enable and disable themes and plugins. Cool, huh? The following is the screenshot of the network Dashboard window:

Tip
Downloading the example code
You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
Congratulations! You've created your first WordPress multisite network! Wasn't too bad, was it? In the next chapter, you'll use the knowledge gained here to really put multisite to use. We'll be covering customization, including building out a custom Blog Directory page, with Gravatar support and all.