Multiple multiple Mediawiki wikis from a single install

Since I prefer to use the FreeBSD ports tree to install and update software on my server, it is a pain having multiple installs of different versions of the same software scattered across different directories. My goal has been to run all web-based software from a single code base, yet I want the data maintained by these multiple wikis to be separated.

Here is how this can be done in Mediawiki, allowing for separate wikis reading from separate databases:

  1. Make a copy of a virgin Mediawiki database, perhaps calling the database “wikidb_template” (note, you’ll have to keep the schema stored within this DB up-to-date across Medawiki releases, this is explained below…)
  2. Make a copy of Mediawiki’s LocalSettings.php file. Name it something like “LocalSettings-mywiki.php”, where “mywiki” is the name of your wiki.
  3. Create symbolic links from your Mediawiki codebase to the directories you wish to be served by your Mediawiki wiki
  4. Replace the original LocalSettings.php file with something like the following, matching “mydomain.com” with your domain, and the path names to paths matching your symbolic linked directories:

    if (preg_match('/(www\.)?yourdomain.com/', $_SERVER['SERVER_NAME']) && preg_match(’/^\/mywiki/’, $_SERVER['REQUEST_URI'])) {
    // settings file for wiki in path starting with “/mywiki”
    include ‘LocalSettings-mywiki.php’;
    }
    elseif (preg_match(’/(www\.)?yourdomain.com/’, $_SERVER['SERVER_NAME']) && preg_match(’/^\/anotherwiki/’, $_SERVER['REQUEST_URI'])) {
    // settings file for wiki in path starting with “/anotherwiki”
    include ‘LocalSettings-anotherwiki.php’;
    }

  5. Edit each LocalSettings file to modify the database connection information to match the database credentials you have established for each wiki
  6. Create another LocalSettings file pointing to your wikidb_template database. This way, you’ll be able to update the schema to your virgin database as necessary using the Mediawiki web interface updater
Published in: open source software | on May 18th, 2007 |

You can leave a response, or trackback from your own site.

One Comment Leave a comment.

  1. On May 18, 2007 at 9:59 am NetMusician Labs » Blog Archive » Password protect your Mediawiki wikis Said:

    [...] Documenting the technology that drives NetMusician « Multiple Mediawiki wikis from a single install [...]

Leave a Comment