57°F

Aaron Parecki

  • Articles
  • Notes
  • Photos
  • Multisite MediaWiki

    June 12, 2010

    A short guide to setting up MediaWiki to work on multiple websites using the same codebase.

    Prerequisites

    • mod_rewrite
    • mod_env
    • Assumes you are installing multiple wikis on different domains at the root of each domain.

    Apache Configuration

    Set up a virtualhost block for each domain that you are hosting. All the DocumentRoots will point to the same location, the location that you extracted the MediaWiki files.

    <VirtualHost *:80>
        ServerName example.com
    
        DocumentRoot /web/sites/mediawiki
        <Directory /web/sites/mediawiki>
            Options FollowSymLinks
            AllowOverride All
            allow from all
    
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule ^(.*)$ /index.php [L,QSA]
            RewriteRule ^$ http://%{HTTP_HOST}/Main_Page [R=permanent,L]
    
            SetEnv MEDIAWIKI_PATH site1
        </Directory>
    
        Alias /images /web/sites/mediawiki/images/site1
    </VirtualHost>
    

    I use SetEnv to provide PHP with an environment variable accessible via $_SERVER['MEDIAWIKI_PATH'], but you could just as well use $_SERVER['SERVER_NAME'] if your files are named appropriately.

    LocalSettings.php

    Replace your default LocalSettings.php file with the following:

    define('MW_INSTALL_PATH', dirname(__FILE__));
    
    $wgScriptPath       = "";
    $wgScriptExtension  = ".php";
    $wgArticlePath = '/$1';
    $wgUsePathInfo = true;
    
    require_once('config/' . $_SERVER['MEDIAWIKI_PATH'] . '.php');
    
    $wgUploadDirectory      = $IP . '/images/' . $_SERVER['MEDIAWIKI_PATH'];
    $wgUploadPath           = $wgScriptPath . '/images';
    

    You will then move your individual sites' LocalSettings.php files into the config/ folder and name them with the name you used for the MEDIAWIKI_PATH environment variable.

    Images and Uploads

    Create a subfolder in your images folder for each site. Use the identified set by MEDIAWIKI_PATH or use SERVER_NAME instead.

    Installation

    The only hack you'll have to do is tell config/index.php that your wiki isn't yet installed by commenting out the check for the LocalSettings.php file.

    Find the call to writeSuccessMessage(); and comment out that block of code.

    You should then be able to visit http://example.com/config/index.php and run through the setup process to create a new wiki. Of course you should disable access to this file as soon as you're done setting it up so it can't be abused.

    Sat, Jun 12, 2010 10:32pm -07:00
Posted in /articles

Hi, I'm Aaron Parecki, Director of Identity Standards at Okta, and co-founder of IndieWebCamp. I maintain oauth.net, write and consult about OAuth, and participate in the OAuth Working Group at the IETF. I also help people learn about video production and livestreaming. (detailed bio)

I've been tracking my location since 2008 and I wrote 100 songs in 100 days. I've spoken at conferences around the world about owning your data, OAuth, quantified self, and explained why R is a vowel. Read more.

  • Director of Identity Standards at Okta
  • IndieWebCamp Founder
  • OAuth WG Editor
  • OpenID Board Member

  • 🎥 YouTube Tutorials and Reviews
  • 🏠 We're building a triplex!
  • ⭐️ Life Stack
  • ⚙️ Home Automation
  • All
  • Articles
  • Bookmarks
  • Notes
  • Photos
  • Replies
  • Reviews
  • Trips
  • Videos
  • Contact
© 1999-2025 by Aaron Parecki. Powered by p3k. This site supports Webmention.
Except where otherwise noted, text content on this site is licensed under a Creative Commons Attribution 3.0 License.
IndieWebCamp Microformats Webmention W3C HTML5 Creative Commons
WeChat ID
aaronpk_tv