Categories
post

Multiple WordPress Blogs in One Installation

I have been hosting multiple wordpress blogs in one installation for a few years now. I like that I can upgrade one installation, and they all upgrade. I don’t have to go through 10 different installs/upgrades.

There are a few things that can be considered either a pro or a con based on your point of view. If one blog uploads a theme or a plugin, it is available to all the others. This doesn’t mean that if one enables it, they all have to have it enabled. It’s just there, so each can install if they need to.

One serious downside is customization. If one blog customizes a template, another blog can’t use it unless they too want that customization.

On to the nitty-gritty, all I do is change the wp-load.php file and copy the wp-config.php file. I copy the wp-config.php to wp-config-DOMAINNAME.php (example wp-config-www.johncongdon.com.php). Each config file changes the database table prefix.

Here is a diff for the wp-load.php file. It just changes an if statement to load our individual config, if it doesn’t exist, it loads the original wp-load.php.

--- wp-load-orig.php	2011-03-07 15:18:12.000000000 -0500
+++ wp-load.php	2011-03-07 10:30:04.000000000 -0500
@@ -24,7 +24,12 @@
 else
 	error_reporting(E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING);
 
-if ( file_exists( ABSPATH . 'wp-config.php') ) {
+if ( file_exists( ABSPATH . 'wp-config-'.$_SERVER['SERVER_NAME'].'.php') ) {
+
+  /** The config file resides in ABSPATH */
+  require_once( ABSPATH . 'wp-config-'.$_SERVER['SERVER_NAME'].'.php' );
+
+} elseif ( file_exists( ABSPATH . 'wp-config.php') ) {
 
 	/** The config file resides in ABSPATH */
 	require_once( ABSPATH . 'wp-config.php' );

Leave a Reply

Your email address will not be published. Required fields are marked *