tobias.kochs-online.net

Multiple blogs with a single WordPress installation

| 4 Comments

When I started setting up the blogs some days ago, I began to create subdomains and subdirectories on the server where I could install WordPress. Soon I discovered, how complicated and prone to errors this procedure can be and started to think about alternatives allowing me to run several separate blogs while administrating and maintaining only a single software installation. You can find some more or less complex hacks for this floating around the net. In addition there exists a special multi user/multi blog version of WordPress called WordPress µ, but it seems it is turned mostly towards very large projects and uses a number of modifications of the original variant for this purpose. On the other hand there is an approach by Strider which is called Virtual Multiblog and looks quite feasible. However this looks a bit intricately at first glance because it seems to require an additional WordPress plugin.

Finally I discovered a very elegant way by myself: Because WordPress stores all settings of a blog – including articles, comments and users – in the MySQL tables defined in the file wp-config.php, it would be sufficient to use different configuration files depending on the used subdomain. So I modified the wp-config.php to simply evaluate the used subdomain and load a configuration based on the result. Which looks like this:

<?php
if ($_SERVER['SERVER_NAME'] == 'blog1.example.com')
{
require('wp-config.blog1.php');
}
else if ($_SERVER['SERVER_NAME'] == 'blog2.example.com')
{
require('wp-config.blog2.php');
}
?>

The files wp-config.blog1.php and wp-config.blog2.php are just standard WordPress configuration scripts without a single line of extra code. Using different prefixes for the MySQL tables it even would be sufficient to have a single database to store all blogs. As simple as it is, as low-maintenance it is too, because WordPress updates don’t overwrite the new wp-config.php or the newly created configuration files. At the same time all blogs benefit from the update, of course.

[Update: It just caught my eye, that you might run into difficulties if you are running multiple blogs with the same plugin. If an upgrade of that plugin requires an update of the plugin’s database table, you have to pay attention to update all of those tables (for every blog using the plugin)!]

Author: Tobias

Hallo, ich bin Tobias. Meine Leidenschaft gilt alten Autos. Je ausgefallener desto besser. Im Alltag schwöre ich auf meinen treuen '88 Volvo 745 und im Laufe der Zeit sammelten sich daneben in der Garage noch ein '79 AMC Pacer, ein '70 Chrysler 300 Hurst, ein '90 Toyota Sera und ein '94 Mazda 121 Ginza. Wenn ich gerade nicht an den Autos herumschraube, lasse ich den Nerd raushängen und schreibe hier irgendwas zu Online- und IT-Themen, Filmen oder Musik. Ihr findet mich auch .

4 Comments

  1. Hi —

    Just FYI — Virtual Multiblog doesn’t require the plugin; it’s optional. The plugin turns on a diagnostic screen in admin.

    Ultimately, the base system is extremely similar to what you ended up doing. 🙂

  2. Damn! I should have looked closer. 🙂

  3. Udn wie schaut es aus wenn WP eine Aktualiesierung fährt wie z.B. die von letzte Woche auf WP 3.0. zerschiest dir das dann nicht alles ?

  4. Well, of course you can never be 100 % sure a major update won’t crash your installtion. So you might better be a bit careful there (i.e. do a backup). On the other hand I never had any problems upgrading.
    However I haven’t updated to WordPress 3.0 yet. Above all because I wanna have a look at the new Multisite feature first. Maybe I’m going to replace the solution described above by that.

Leave a Reply

Required fields are marked *.