Making a MediaWiki Farm

Posted by & filed under Work.


I was tasked by my boss to create a MediaWiki Farm.  I thought this would give me the opportunity to learn more about MediaWiki, but believe it or not it also helped me learn more about Mac’s “Unix” flavor.

The purpose of the MediaWiki Farm is so that professors can request wikis for academic/research work from our Research and Instruction Department.  The reason we chose to create a farm was so that we could minimize the amount of work necessary to maintain 5 plus MediaWikis (I don’t want to have to update each and every one’s filesystem each time a new version comes out).

Creating the MediaWiki Farm with Symbolic Links

While poking around on my good friend Google I found a lovely page that described How to Create a MediaWiki Farm using Symbolic Links on Mac OS X.  It was nice because it gave me directions.  But as a former Unix person I assumed some of the directions could be improved upon (silly me).  So I set about creating my MediaWiki Farm.

Below are the directions that I followed and what I learned from the process:

  1. Download MediaWiki and unpack it.
    I decided to put everything in a directory named wikis since I have multiple products running on this server. I then asked that the wikis folder be mapped to a new DNS (
  2. Create symbolic links from the unpacked MediaWiki to a template directory.

    ln -s mediawiki-[version] template

    At first I wasn’t sure why I was doing this that way.  Why not just link everything to the unpacked file system?  After thinking about this I realized that it would be easier to update symbolic links once, not 5, 10, 15 times.  But I have to say I’m still on the fence about this, because of the next step.

  3. Create a blank wiki from your template.
    First I created the direcotory the new wiki will reside in.

    cd /Library/WebServer/Documents/wikis
    mkdir [newdirectory]
    cd /Library/WebServer/Documents/wikis/[newdirectory]

    Another thing to consider is creating the AdminSettings.php file. To do this I renamed the sample file and created a symbolic link for it:

    cd /Library/WebServer/Documents/wikis/template
    mv AdminSettings.sample AdminSettings.php
    sudo chmod 744 AdminSettings.php

    You’ll also want to edit the AdminSettings.php file and include super user access. This will help you in updating the wiki later on down the road.

    The next thing I did was create a list of all the files in the template directory. This is why I’m still on the fence about not just linking directly; will I have to create a new list every time I update MediaWiki? I’m sure there is a way to automate this, but I don’t have time to work on this now, I’ll do that later.

    Another thing is that Mac works strangely with symbolic links. If I were to do an ln -s mediawiki-[version] [newdirectory] it would link to everything in that directory. And let’s say I go into [newdirectory] and remove one of the files in the directory using rm wiki.phtml for example. The rm wiki.phtml will not only delete the file in [newdirectory], but also the one in the template directory and the one in the mediawiki-[version] directory. I discovered this when I went in and symlinked the template to [newdirectory] using ln -s template [newdirectory]. I ended up having to start over.

    So I created a symlink for each of the files and the subdirectories:

    ln -s /Library/WebServer/Documents/wikis/template/api.php
    ln -s /Library/WebServer/Documents/wikis/template/AdminSettings.php
    ln -s /Library/WebServer/Documents/wikis/template/api.php5
    ln -s /Library/WebServer/Documents/wikis/template/COPYING
    ln -s /Library/WebServer/Documents/wikis/template/docs
    ln -s /Library/WebServer/Documents/wikis/template/extensions
    ln -s /Library/WebServer/Documents/wikis/template/FAQ
    ln -s /Library/WebServer/Documents/wikis/template/HISTORY
    ln -s /Library/WebServer/Documents/wikis/template/img_auth.php
    ln -s /Library/WebServer/Documents/wikis/template/img_auth.php5
    ln -s /Library/WebServer/Documents/wikis/template/includes
    ln -s /Library/WebServer/Documents/wikis/template/index.php
    ln -s /Library/WebServer/Documents/wikis/template/index.php5
    ln -s /Library/WebServer/Documents/wikis/template/INSTALL
    ln -s /Library/WebServer/Documents/wikis/template/
    ln -s /Library/WebServer/Documents/wikis/template/languages
    ln -s /Library/WebServer/Documents/wikis/template/locale
    ln -s /Library/WebServer/Documents/wikis/template/maintenance
    ln -s /Library/WebServer/Documents/wikis/template/Makefile
    ln -s /Library/WebServer/Documents/wikis/template/math
    ln -s /Library/WebServer/Documents/wikis/template/opensearch_desc.php
    ln -s /Library/WebServer/Documents/wikis/template/opensearch_desc.php5
    ln -s /Library/WebServer/Documents/wikis/template/profileinfo.php
    ln -s /Library/WebServer/Documents/wikis/template/README
    ln -s /Library/WebServer/Documents/wikis/template/redirect.php
    ln -s /Library/WebServer/Documents/wikis/template/redirect.php5
    ln -s /Library/WebServer/Documents/wikis/template/redirect.phtml
    ln -s /Library/WebServer/Documents/wikis/template/RELEASE-NOTES
    ln -s /Library/WebServer/Documents/wikis/template/serialized
    ln -s /Library/WebServer/Documents/wikis/template/skins
    ln -s /Library/WebServer/Documents/wikis/template/StartProfiler.php
    ln -s /Library/WebServer/Documents/wikis/template/t
    ln -s /Library/WebServer/Documents/wikis/template/Test.php
    ln -s /Library/WebServer/Documents/wikis/template/tests
    ln -s /Library/WebServer/Documents/wikis/template/thumb.php
    ln -s /Library/WebServer/Documents/wikis/template/thumb.php5
    ln -s /Library/WebServer/Documents/wikis/template/trackback.php
    ln -s /Library/WebServer/Documents/wikis/template/UPGRADE
    ln -s /Library/WebServer/Documents/wikis/template/wiki.phtml

    Essentially the reason I’m creating a list is because certain files in the first layer of the directory should not be symlinked (ie. LocalSettings.php and the images directory). So I need to create/copy those files into [newdirectory]:

    mkdir images
    sudo chown www:wheel images
    cp -R /Library/WebServer/Documents/wikis/template/config .
    sudo chmod a+w config

    Ok now we have the file system for a new wiki set up. Next we need to create the database piece.

  4. Create the Database for the MediaWiki
    So in the document on How to Create a MediaWiki Farm on Using Mac OS X, the author creates the database from a shell script. While it seems to make sense, I personally need to know more about how it works before I’ll do this. And I just don’t have the time to do that right now.

    So what I’ll do for now is go to the wiki’s start page and follow the instructions there. Simple enough.

  5. Move the LocalSettings.php file and delete the config directory
    The last step is to move the LocalSettings.php file and delete the config directory. Make sure that when you move the LocalSettings.php file that you’re moving it to the full path name, otherwise if you do a mv LocalSettings.php ../ it’ll end up in the template directory (this is because of the weirdness with Macs and symlinks).

    cd config/
    mv LocalSettings.php /Library/WebServer/Documents/wikis/[newdirectory]/
    cd ..
    rm -rf config

    After you move the the LocalSettings.php file you will need to change permissions on it so that people can’t write or execute the file unless they are the admin user.

    sudo chmod 744 LocalSettings.php

  6. Now your MediaWiki is ready to go!

Next Steps for the MediaWiki Farm

My next posts will be on moving a MediaWiki to the farm and updating a farmed MediaWiki with separate databases for each instance of MediaWiki. These topics of are concerned from me since we are currently in an environment where we have multiple outdated MediaWikis being housed in completely seperate installations. I need to end that, and quickly since its a lot of work to maintain multiple MediaWikis.

Also its important to point out that the reason I chose to use separate databases for each instance of MediaWiki is because of our current environment. It is possible to use one database for all of your MediaWikis, you just append tables with a prefix when you do the install. The reason I’ve chosen not to do this is because importing a database as a database and not as tables is significantly easier than renaming all those tables.

Comments are closed.