Yes it is possible to host multiple sites for multiple customers with WordPress. The Multi User feature we expected in wordpress 3.0 will satisfy most bloggers only but we need something more specific. The technique I describe here is similar to the one described here in the sense that it directs the database configuration constants to specific databases instead of table prefixes as seen elsewhere. The advantage obviously is that you keep a single install of wordpress and only have one codebase to manage , while databases remain independent.
This article will describe the technique I use for secure multi domain worpdress install
we will create wp-mydomains folder, and inside create one subfolder for each domain, example wp-mydomains/mysite.com, with the wave-db-config file and the upload subfolder for,
we will then add the following code to wp-config.php : this coding allows a default domain to remain active even when the configuration file does not exist, at the expense of a loss in performance. But It is useful to show what's missing.
$domain = strtolower( str_replace( "www.", "", $_SERVER["SERVER_NAME"] ) );
$domain = preg_replace('[^a-z0-9\.-]', '', $domain );
$domainDirectory="/wp-domains/" .$domain;
$domainConfig= dirname(__FILE__) . $domainDirectory . "/wave-db-config.php";
if ( file_exists( $domainConfig ) ) {require_once( $domainConfig );} else {
$dbuser="defaultdomaindatabase";
$dbpwd="password";
if ($domain!="defaultdomain.com") echo "missing " .$domainConfig;}
replace definitions with variables, still in wp-config.php
define('DB_NAME', $dbuser);
define('DB_USER', $dbuser);
define('DB_PASSWORD', $dbpwd);
in each domain subfolder , declare the appropriate variables in wave-db-config.php
<?php
$dbname="dbname";
$dbuser="dbusername";
$dbpwd="dbpass9";
$dbprefix="dbprefix";
define( 'UPLOADS', 'wave-wp-domains/mydomain/uploads' );
Once this is working with your default domain, setup virtual hosts in Apache and try a new domain. Remember on a new install to setup the upload folder in wordpress admin settings.
Multi site config for WordPress : Compatible plugins
I'm running the following plugins and they work perfectly
- WP Super Cache : works fine because the cache filename coding alogrithm includes the domain name