WordPress 3.0 Multisite Install

With the looming update of WordPress 3.0 coming out any day now, I decided to upgrade to Release Candidate 1 yesterday. After several hours, database tweaking, and moving some files, I finally have all my blog sites running under one install of WordPress 3.0. One of the new features of 3.0 is being able to control several WordPress sites from one install. This makes it really easy when a new version comes out as you only have to upgrade once and all your sites are on the new version. This was available previously in a branch of WordPress called wordpressmu, but I didn’t find out about it until after I had other sites setup and didn’t want to mess with it. WordPress 3.0 adds this feature to the main program. I figured it was a good time as any to take the time to figure it out. For the most part everything worked, but I did have a few snags on the way. I figured I would document the process for anyone else wanting to do the same thing, so now on to the nerdy stuff.

The first thing I did was upgrade my main blog at mydomain to wordpress 3.0.

Once I verified that everything was working I enabled multisite. You do this by editing your wp-config.php file and add the following line
define('WP_ALLOW_MULTISITE', true);

After you have done that log back in to your site and click on Tools >> Network

From this screen you can decide if you want all future blogs to be subdomains or subfolders. A subdomain is http://subdomain.domain where as subfolders are http://domain/subfolder. I’ve always preferred the subdomain setup as your not telling people to type in slashes when you share the web address. Now you will be given some more code that you need to add to your wp-config.php file again and your .htaccess file in the root of your wordpress install. It varies depending on which install you chose, so here is what I got with a sub domain install.

wp-config.php
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', true );
$base = '/';
define( 'DOMAIN_CURRENT_SITE', 'kemple.us' );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );

.htaccess
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]

# uploaded files
RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule . index.php [L]

Now you are ready to create new sites on your main domain network, but we want to import one that we previously setup. The first thing we need to do is create a new site. Do this by going to Super Admin >> Sites Type the site names you want or an identical one to your existing site, add site title, and admin email. Then click add site. This will automatically create the tables for the new site in your database. If you are using the default wp_ then it should be wp_2_ meaning that it is the 2nd site.

Now you need an export of your other sites current mysql database and open it in a text editor. I used BBedit in my case. What we need to do is change the wp_ in that database to wp_2_ and it can be done fairly quick with a simple find and replace. There are also a couple of other values that need to be changed as well. Previously I set up my wordpress sites under users, so the address was http://www.domain/~user so I did another find and replace, in which I replaced, www.domain/~user with subdomain.domain The other thing that is different is where the uploaded files go. On a standalone install they go to wp-content/uploads where on a new install they go into files, so I did another find and replace to make that change.

Okay, now the database is ready to be imported into the main multisite one. The first thing I did was drop the wp_2_ tables that it had currently created and then imported my edited one. Now you should have all the wp_2_ tables back with all of your old data contained within.

Now that you’ve got all the data in there we just need to move a few files from the old install like uploaded pictures and themes. The themes go into the same directory as before in /wp-content/themes so just copy the ones for your old install there. The uploaded files are a different matter though. You need to move them from the old /wp-content/uploads/ directory into the /wp-content/blogs.dir/2/files/ folder.

Now go back to your main site dashboard and click on Super Admin >> Sites Hover over your new site name and click on edit. Make sure the site url is correct and the upload path is wp-content/blogs.dir/2/files then click save. You also need to enable your theme in Super Admin >> Themes and then click apply changes. Your site should now be set up.

The last step I did was create a virtual host in apache for the new subdomain with the following config

VirtualHost *:80
ServerAdmin [email protected]
ServerName subdomain.domain
ServerAlias http://subdomain.domain
DocumentRoot /path/to/www/
/VirtualHost

Restart Apache and you should be ready to go. To add another old site to the new just follow the above steps, but the next site would use wp_3_ and so on for the tables. The only drawback that I have found in this process is that you lose your users for the subdomains. I didn’t really have that many so it wasn’t a big deal to me, but might be a big issue for someone else with more high traffic blogs.

Leave a Reply