From MyCambrian


How to Create Another Mediawiki on the Same Server, Using the Same Source Code, Using the Same Database, but with its own Tables


You have successfully installed Mediawiki and now want to create another, separate wiki on the same server using new tables but within the same database and using the same source code.


Visitors to your site are presented with MyFirstWiki. You want visitors to to be presented with an entirely different wiki. However, you want to have a single set of source code for both wikis, and you want to keep the tables for both wikis separate but within the same database.

Level of expertise required

If you can get to a Unix operating system prompt and type in a few basic Unix commands, you'll be fine!

Time required

Because I spent my entire evening documenting this for you, it'll take you only 15 minutes. Give a little, get a little, right? It makes the world a nicer place :-)

What this does

This will accomplish exactly the scenario described above. When you're done, for each wiki you'll have:

  • a separate LocalSettings.php file for each wiki (Alternative: You might be able to run the system using only a single LocalSettings.php. You would have to modify the startup routine so that the system can determine which wiki is being accessed and set the configuration variables for that wiki.)
  • a separate images directory for each wiki (Why? Necessary so that each wiki has its own library of images. If you you want your wikis to share the same library of images, not needed.)
  • a separate "virtual" directory for each wiki (Why? This is necessary so that, when the user clicks links within your wiki, they will be taken to the correct index.php for each wiki)


I did this using the following configuration:

  • MediaWiki 1.5.1
  • Shared hosting server running Apache 1.3.34


Before starting, you need to know these two items:

  1. What is the directory of your current, working Mediawiki installation where the index.php file is located? Example: /home/yourdomain/www/wiki
  2. What is the directory where you want to create your new wiki? Example: /home/yourdomain/www/new/wiki

And, if you're doing this on a remotely-hosted server, you'll also need:

Telnet or SSH access to your server so that you can type operating system commands. I use a free client called PUTTY.exe. You can find these programs online and your hosting provider will tell you how to configure it. Using a program that does only file transfers is not sufficient.

And, if you are using Apache and/or SELinux:

At least two users have commented that you need to have FollowSymLinks in your Apache config for this to work. (On my shared hosting server, this setting must have been already enabled because I didn't have to deal with it. If anyone knows how to verify this setting and/or enter it in the config, let me know and I'll update this page).

Unix commands that you’ll use

  • ln = link (we are using the -s option, which creates a "symbolic link", like a shortcut in Windows)
  • cp = copy a file or directory
  • mkdir = make a new directory
  • rm = remove a file
  • cd or cwd = change directory, or, change the working directory

Unix commands that are helpful

  • ls = list the files/directories, i.e. ls -la
  • pwd = display the current directory you are in (print working directory)

PART A – Install the Mediawiki files

  • Note that many of the following commands have a  . (space followed by a period/fullstop)-- this period means "the current directory"
  • NOTE: in the "Comments and Feedback" section, there is a script to automate this Step A. See "Automated installation via shell script".

  1. login to your server using your telnet or SSH client so that you can enter commands from the Unix operating system prompt. I used Putty.exe.
  2. create the base directory where you want to install the new wiki. Let's call this the "new base directory":
  3. mkdir /home/yourdomain/www/new/wiki
  4. change to the new base directory:
  5. cwd /home/yourdomain/www/new/wiki
  6. below the new base directory, create an "images" sub-directory (this directory will contain any image files that get uploaded to this new wiki):
  7. mkdir images
    mkdir /home/yourdomain/www/new/wiki/images
  8. below the new base directory, create a "config" sub-directory (Mediawiki will create your new LocalSettings.php here):
  9. mkdir config
    mkdir /home/yourdomain/www/new/wiki/config
  10. Make the config directory writable:
  11. chmod a+w config
    chmod a+w /home/yourdomain/www/new/wiki/config
  12. Link in all the files, except LocalSettings.php, by doing this:
    1. In one easy command, link all the files that are in your current, working base directory to your new base directory:
    2. ln -s /home/yourdomain/www/wiki/*.* .

    3. then, remove LocalSettings.php from being linked in:
    4. rm LocalSettings.php

    • "Linking" in Unix is similar to creating a "shortcut" in Windows-- it appears to the operating system that the file exists in two places, but really it exists only in your original working directory. This is how you are able to have just one set of source code powering more than a single wiki.
    • NOTE: in the "Comments and Feedback" section, there are shortcuts given for combining steps 7 and 8
    • NOTE/FYI/WARNING: if you later create a new file or sub-directory in the linked (virtual) directory, it is actually created in the original directory and then is available in both the linked location and the original directory.
  13. Link in the remaining directories, shown here in alphabetical order, EXCEPT don’t link in the "config" or "images" directories. You can do it all in one line, like this:
  14. ln -s /home/yourdomain/www/wiki/{docs,extensions,includes,languages,maintenance,math,skins,tests} .

    or, you can link in each directory individually, like this:

    (don’t link in "config" dir)
    ln –s /home/yourdomain/www/wiki/docs .
    ln –s /home/yourdomain/www/wiki/extensions .
    (don’t link in "images" dir)
    ln –s /home/yourdomain/www/wiki/includes .
    ln –s /home/yourdomain/www/wiki/languages .
    ln –s /home/yourdomain/www/wiki/maintenance .
    ln –s /home/yourdomain/www/wiki/math .
    ln –s /home/yourdomain/www/wiki/skins .
    ln –s /home/yourdomain/www/wiki/tests .

    Dean Stringer wrote to say that his version (1.9.1) also includes a directory named "serialized" and he needed to link in that directory, too. To link it in, add "serialized" to the list of directories above, like this:

    ln -s /home/yourdomain/www/wiki/{docs,extensions,includes,languages,maintenance,math,skins,tests,serialized} .

    or, for you one-at-a-time linkers:

    ln -s /home/yourdomain/www/wiki/serialized .

  15. Link in the configuration script file that will set up the wiki:
  16. cd /home/yourdomain/www/new/wiki/config
    ln -s /home/yourdomain/www/wiki/config/index.php .

You're doing great! Now the source code is ready for you to run the Mediawiki setup/configuration routine which creates the tables in the database. Continue with Part B.

PART B - Create the Tables in the Database

  1. Browse to the index.php in the new base directory:

    The MediaWiki installation program should start. Setup your new wiki just as you did your first wiki, but be sure to specify a DATABASE TABLE PREFIX for the new wiki tables. For example, the prefix for the tables in my first wiki is myc_ and the prefix for the tables in my second wiki is abc_.

    If you created your first wiki without giving the tables a prefix, you have two options (I like everything nice and tidy, so I prefer the second option):
    1. Continue using them as-is without a prefix (and assign a prefix only to your new wiki), or
    2. Do the following:
      1. Manually rename the tables (i.e. use mySQL or phpMyAdmin to RENAME each of the tables with a prefix, such as "myc_", then
      2. Edit your existing LocalSettings.php file and set the variable $wgDBprefix with your new prefix, like this: $wgDBprefix = "myc_";
    • NOTE: Bob Judd reports that his mySQL database was not found because his hosting provider assigns a prefix to all databases. He had to edit the default database name "wikidb" to "mydomain_wikidb".
  3. Just as when doing a regular install the MediaWiki software, once you have completed the installation of your new wiki you must move the file LocalSettings.php from the config directory that is below your new base directory up one level to your new wiki's base directory. Here's how:
    1. Make sure you are in the new wiki’s base directory:
    2. cd /home/yourdomain/www/new/wiki

    3. Move the file:
    4. mv config/LocalSettings.php .

    5. Optionally, you may remove the config directory that is below your new base directory:
    6. rmdir config

    You’re done! Your software is all set and if you look in your database (i.e. use phpMyAdmin), you should see a separate set of tables for each wiki.

  4. Start your new wiki by browsing to:

Give Love, Give Feedback

So, what do you think? Was this useful to you? Show a little love-- what's your feedback? email me

Comments 'n Questions from Users

Combining steps 7 and 8

Steps seven and eight can be combined. In Unix, * means "everything" so both all files and all directories (you don't need *.* to copy all files as in Windows: * will copy file, file.extension and .extension as well as all directories). BUT, ln -s somedirectory/* . will not overwrite existing directories--so you don't have to worry about step 8.

For step seven then, just do

     ln -s /home/yourdomain/www/wiki/*
  • NOTE: Bob Judd reports that he needed to use ln -s /*.* .

Skip step 8, then

     rm LocalSettings.php

Another Trick to Save Time

Hi Steve,

I recently found your wiki farm setup tutorial quite helpful. Thank you for your good work.

To "show a little love", I have a suggestion on linking files :)

In Step 8 (Part A), you can link multiple directories in a single command like this:

  ln -s /home/yourdomain/www/wiki/{docs,extensions,includes,languages,maintenance,math,skins,tests} .

This might save some copy/paste time, and no risk of deleting the real "LocalSettings.php" file.

Thanks again for your nice tutorial.

Regards, Dave

>> That's a good tip, Dave. I have added your code to the main instructions, and I've even given it the high honor of being shown before my own instructions (I'd say that's almost equivalent to being granted knighthood! :-) Thanks for sharing it. --Steve

DocumentRoot on Apache

The only trouble I had was associated with apache. I had to set the DocumentRoot, which had been set to /var/www/wiki, back to /var/www in order to be able to access the second wiki which was on /var/www/wikiXXX. Once this was done, I could go to the server/wikiXXX and set it up sucessfully. However, I had to put the first one then on /var/www/wikiYYY, set it up in a simiar way, and put the prefix of the first one in. Suprisingly, that wiki pages in this one all pointed back to the Documentroot. Editing the main file, saving it resolved the problem. Best regards, Peter

>> Thank you for the feedback, Peter. I'm sure others will find this useful. --Steve


First, let me say thank you for sharing your guide on setting up mediawiki with a single source/database. As an admin responsible for about 10 separate mediawiki-based wikis, it is certainly an appealing idea, and I appreciate you taking the time to detail this setup.

One thing your guide doesn't address though is upgrading. It would seem to me that the main advantage of setting mediawiki up in this way would be to simplify the upgrade process. I'm running into a problem with the LocalSettings.php file when I do this though.

When I run the "php update.php" command, I get the error, "A copy of your installation's LocalSettings.php must exist in the source directory."

I've tried:

  • creating a symlink from the new mediawiki src folder back to the LocalSettings.php file in the wiki I'm trying to upgrade
  • specifying an explicit LocalSettings.php location in the file in the maintenance folder. This seems to be where the code is that is working with the LocalSettings.php file during an upgrade.

(I'm not familiar with the syntax of PHP, so I can only partially tell what the file is doing.)

Neither of these seemed to have any effect at all, at least not the way I did it.

Have you tried performing an upgrade on a combination of wikis setup in the way your guide describes? Were you able to get past this issue, and if so, would you mind posting your solution to your guide?

Thank you for your time, Jeremy

>> I'm using v1.5 and I haven't upgraded yet (because v1.6 needs PHP5 and my hosting provider hasn't upgraded PHP on the servers). Can anyone help Jeremy? --Steve

Possible solution: I've been having the exact same problem. The only solution I've found so far is to copy the LocalSettings.php file of the wiki I'm wanting to update into the directory of the source wiki and then running update.php. Since I have no LocalSettings.php of any wiki I'm running in that directory, that's no real problem. --Denise 13:40, May 18, 2007 (CDT)

>> I had the same problem not getting the upgrade to the database schema. The source directory in the case happened to be the same directory that I was running update.php from! In your case I guess you'll have to substitute the LocalSettings.php config with db logins for each of your 10 sites. You will also need to configure a admin user that can change the schema. --Pierre

Apache under Windows

I wanted to set up multiple wikis but my Apache server runs on Windows, so the link technique you suggested doesn't work.

First, I went to and made two urls, both pointing to my server (e.g.,

Next, I made two copies of my LocalSettings.php:


I edited LS_site2.php to have a new name and database connection (recreating the db structure etc.). Then, I inserted the following into index.php:

    $localsettingsfile = 'LocalSettings.php';
    $callingurl = strtolower($_SERVER['HTTP_HOST']);
    if (FALSE !== ($match = strpos($callingurl, 'site1URL'))) {
        $localsettingsfile = 'LS_site1.php';
    if (FALSE !== ($match = strpos($callingurl, 'site2URL'))) {
        $localsettingsfile = 'LS_site2.php';

and changed:

    # Include this site setttings
    require_once( './LocalSettings.php'  );


    # Include this site setttings
    require_once( './'.$localsettingsfile  );

This seems to work fine. Of course, you could point the different settings files to a directory outside of the wiki install. Also, you could make this a script outside index.php that it called so that it is easier to maintain (add new wikis). For a large number of wikis, it should be easy to have the switching function do a database lookup and to direct to the right wiki.

Just thought I'd pass this on, as your guide was helpful. Perhaps you can post some of this for non-linux users that find your page.

Thanks, Bob

>> Thanks for the detailed account, Bob. Together, our war stories will make the world a better place. Well, at least our wikis will be better. -- Steve

Thanks a Million

Hi Steve,

Found your wiki help page and I wanted to thank you for the help! Instead of wasting 8 hours fumbling around I was able to get 3 wikis up and running in under an hour!

Thanks a million.

Cheers, Rob

>> You are quite welcome. And thanks for the feedback! -- Steve

How to Get Relief and View the Setup Menu

Hello Steve,

This explanation was quite a relief for me. After looking at, their explanation didn't work for me. All I wanted to add as a comment to your site is that, in Section 9, you could explain that if you want to get to the Setup Menu, the file LocalSettings.php of the old installation MUST be in the config directory. If it was previously removed, the setup will display as 'website installed already.' Luckily, I figured out this part.

Thanks ! Jan

>> Thank you for pointing that out, Jan. And, I'm glad you found relief in my explanation :-) --Steve

No time? No problem!

Hi Steve,

Thanks for your documentation on multiple wiki instances with mediawiki. I was able to setup 5 wikis in no time.

Thanks, Abhik

>> Yea! I'm glad it was helpful. I love to hear it! --Steve

Thanks for your wikihelp


Thanks for that. Made it very simple and quick.


>> You're welcome, John. Glad you could make use of it! --Steve

Apache config needs FollowSymLinks

This was easy to follow and made total sense to this Linux admin. I was able to adapt it to my needs. Thank you.

HELPFUL NOTE: You need to have FollowSymLinks in your Apache config for this to work.

- Gavin

>> Compliments from a real sysadmin -- wow, you made my day! --Steve

SELinux might need FollowSymLinks


Great help page. This short-circuited a wiki farm setup I'm working on by several hours.

BTW, for those running any version of Linux with SELinux enabled, the SELinux config may need to be tweaked to permit FollowSymLinks to work for Apache. That was my only "lesson learned" in this endeavor.

Thanks again.

Kirk Leggott

>>I'm glad to hear it! And, thanks for the additional info. --Steve

And even more about FollowSymLinks

If there is a problem with FollowSymLinks, it can be added to .htaccess in the root www/ folder of an account; it does not need to be done by a sysadmin. At the apache root: add this line

Options +FollowSymLinks

at top of .htaccess


>>Thanks, Bob. FYI, I added a period after the word "sysadmin" to (hopefully) clarify your note. If my edit altered the meaning, let me know. --Steve

Minimalist Is In

Hello Steve,

I've just installed mediawikis on a couple of my domains, and, thanks to your instructions, there's minimal duplication of code. Thank you!

>>Okay, I'll interpret "minimal duplication" as being close to perfection :-) Thanks for the feedback --Steve

Limitations to a True Godsend?

Hey Steve,

I'd like to start by saying thanks for your very helpful wikihelp section. It is truly a godsend. Second, I wanted to ask if there was a limit to the amount of wikis I can have using the same source code?

Thanks, Zach

>> I'm not aware of any limitation other than the amount of traffic that your server can handle. But, it would be best to ask the developers; you can chat with them on IRC. --Steve

Automated installation via shell script


some time ago i wrote follwing script to automate step A:

#! /bin/bash
if [ $# -ne 0 ]
  if [ $# -eq 2 ]
  mkdir $target
  cd $target
  mkdir images
  mkdir config
  chmod a+w config
  for file in `ls $base | fgrep ".php
    if [ "file" != "LocalSettings.php" ]
     ln -s $base/$file
  ln -s $base/bin
  ln -s $base/extensions
  ln -s $base/includes
  ln -s $base/languages
  ln -s $base/locale
  ln -s $base/maintenance
  ln -s $base/math
  ln -s $base/serialized
  ln -s $base/skins

  cd config
  ln -s $base/config/index.php .
  echo "Files linked and created. Now visit your new wiki-copy to run setup"

        echo "Usage: create_mediawiki <target-directory>"
        echo "   or: create_mediawiki <target-directory> <mediawiki-base>"

I think usage is self-explaining. Just copy this scirpt to a file named create_mediawiki and edit base=/webs/andi/root/software/mediawiki_1_9 to point to your source.

Important: There mustn't be any withespace before .inc!

I use svn to get this file base on the recent version.

Have fun.

--Saerdnaer 15:49, April 13, 2007 (CDT)

>> Thank you Saerdnaer for providing this-- I'm sure it's going to be helpful to many users.--Steve

Sometimes, hard is better

Hi Steve,

I had to have hard copy of new/wiki/index.php folder, not a linked file.

I also had to have hard copy of new/wiki/config/index.php, not a linked file.

AND, this was rather significant, it had to be the original config/index.php file that came with the installation package, NOT the one that was left lying around from the first installation!

So I finally did successfully set up the new wiki!! Huzzah! Thanks for your moral support and for your web site, which made my struggle easier and successful!!

Bob Judd

>> I see that you're an excellent problem solver, Bob. I added your other feedback as "Notes" in the appropriate places on this page. Thanks for the tips! --Steve