Host multiple WP sites on one installation

Written by LobsterMan | Thursday, August 10th, 2006
, ,

Most of the basic shared hosting plans will only allow you to use 1 domain name and a limited number of databases. So what do you do if you want to set up more then one WordPress powered site on your hosting plan? Here’s a solution.

Most hosts will allow you to ‘park’ or ‘forward’ additional domains to your hosting plan, but they will show the same site, they can’t be configured to show content from different places. but because the actual files of a WordPress installation are the same, and all the information is stored in the database, we can manage a workaround. What we will do is set up WordPress to use different databases depending on the domain name entered in the browser window.

You will only need to edit 1 file, so this make future updating of your WordPress installation pretty simple. In fact, even if you have your own server, this method might help you keep all your wordpress sites up to date.

Here are the simple steps:

  1. Upload the WordPress files to your server.
  2. Copy the following code to a text editor, and enter your database settings (note: you will have to delete the space between ‘< ' and '?php' in the beginning of the document.)

    < ?php
    // ** MySQL settings ** //
    define('DB_NAME', ''); // The name of the database
    define('DB_USER', ''); // Your MySQL username
    define('DB_PASSWORD', ''); // ...and password
    define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value

    // table prefix, for hosting multiple intalltaions in the same db.
    $table_prefix = ereg_replace('^(www\.)', '', $_SERVER['HTTP_HOST']);
    $table_prefix = ereg_replace('\.', '', $table_prefix);
    $table_prefix = $table_prefix . '_';

    // Change this to localize WordPress. A corresponding MO file for the
    // chosen language must be installed to wp-includes/languages.
    // For example, install de.mo to wp-includes/languages and set WPLANG to 'de'
    // to enable German language support.
    define ('WPLANG', '');

    /* Stop editing */

    define('ABSPATH', dirname(__FILE__).'/');
    require_once(ABSPATH.'wp-settings.php');
    ?>

  3. Save the file as wp-config.php and upload to your sever (where the regular wp-config.php file normally is)

That’s it!

Now, every domain (or sub-domain) you have pointing at this WordPress installation will use a different prefix for it’s tables in the database, so they are totally different, using different settings and data stored in the database.

To add another site, just set up the domain (or sub-domain) ‘pointing’ then visit that domain and follow the wordpress installation process.

Credits: this technique is based on the more complex technique (better for hosting solutions) from OldBrownShoe.org

Related Posts:

2 Responses to “Host multiple WP sites on one installation”

  1. goju.ca » Blog Archive » Host multiple WP sites on one installation Says:

    [...] Found an interesting article on hosting multiple WP sites within a single installation. Basically they prefix each WP site within the database schema with the site url and redirect on the requests. [...]

  2. Wordpress – sestavení, pluginy, linky | Phire Base - Graphic, Webdesign, Inspiration. Adobe & WP Says:

    [...] another multilingual manager x2). Polyglot WordPress random header plugin Season Style Switcher Host multiple WP sites on one installation · Attackr.com Multiple WordPress blogs on one domain or two if poss, how to do it? This entry was posted on [...]

Leave a Reply

 
Stop Censorship