[Mediawiki-l] Running several MediaWiki sites from the same PHP files

Joshua Yeidel yeidel at wsu.edu
Fri Apr 7 23:24:30 UTC 2006


We are working on this right now.  NOTE: You must understand PHP to apply
this approach.

Our basic idea is this:

1) within the MediaWiki install folder, we create a "wsu" folder, to contain
all files we add to MW (that makes it easier to upgrade when a new version
of MW comes out).  

2) Within the "wsu" folder, we make a folder for each wiki.  These folders
are named with the "wikiname" (= sitename) for the wiki.  They might contain
images or whatever is needed by that particular wiki.  They also contain a
file "LocalSettings_".wikiname.".php" which contains any special settings
for that wiki that override or extend the common LocalSettings.php in the
main Mediawiki install folder.  So for "joshwiki", we have a folder
"wsu/joshwiki" which contains "LocalSettings_joshwiki.php".  [The file
doesn't logically need to have the wikiname in its filename, but it makes it
easier to keep track when you're editing.]

2) At the end of LocalSettings.php in the main MW folder, we determine which
wiki was called by parsing the request URI, and store the result in a
superglobal.  [Note that we have a different $wgArticlePath and
$wgScriptPath, in order to manage pretty URL's via our load balancer.
Incoming URL's point to the 'wikishortname' + 'wk';  outgoing URL's point to
'wikishortname' + 'wiki'.]

if (!isset($GLOBALS['wsuWikiname'])) {
     $uri = $_SERVER['REQUEST_URI'];

#    find first element of called URI
     preg_match("|^/(.*)wk/|",$uri,$matches);
    if ($matches) {
        $GLOBALS['wsuWikiname'] = $matches[1].'wiki';
        $GLOBALS['wsuWikiuri'] = $matches[1].'wk';
         error_log("wikishortname = $matches[1]");
    } else {
        error_log("malformed URL: $uri");
    }
}

Then we require_once Local_Settings_wikiname.php for that wiki, which
contains any needed overrides or additions to the common settings in
LocalSettings.php:

#    Choose the appropriate LocalSettings file for per-wiki overrides
#     per-wiki LocalSettings is places in per-wiki directory in wsu/
#
     require_once 'wsu/'.$GLOBALS['wsuWikiname'] . '/LocalSettings_' .
$GLOBALS['wsuWikiname'] . '.php';

3) You have to be quite careful about settings with dependencies on other
settings.  Here is the tree I developed of dependencies in
LocalSettings.php:

[Mediawiki 1.5.6]
*Request URI
**$GLOBALS['wsuWikiname']
***$wgSitename
****$wgLocalInterWiki
***$wgDBname (yes, we generate the DB name from the wikiname)
***$wgArticlePath
***$wgDebugLogFile (separate debug log file for each wiki)
***per-wiki directory
***per-wiki local settings name
**$GLOBALS['wsuWikiuri']
***$wgScriptPath
****$wgScript
****$wgRedirectScript
****$wgStylePath
****$wgUploadPath

You don't want to do an override on a setting without also overriding the
things that depend on it.

NOTE THAT THIS IS NOT YET RUNNING except on a limited basis in development.
Only you are responsible if you believe what you read here, put it on a
machine, and get hurt.

HTH,

-- Joshua

 
On 4/7/06 1:24 PM, "Rotem Liss" <mail at rotemliss.com> wrote:

> I'm running three MediaWiki sites, and I copy the PHP files from folder
> to folder. Can I run them somehow from the same PHP files, so I won't
> need to copy and update all the files three times? By the way, how do
> you do that in Wikimedia sites - copy the PHP files, or using the same
> ones? And how do you do that?
> 
> (Of course, using different LocalSettings.php for every site, and
> running from other folders.)
> 
> rotemliss
> 
> _______________________________________________
> MediaWiki-l mailing list
> MediaWiki-l at Wikimedia.org
> http://mail.wikipedia.org/mailman/listinfo/mediawiki-l




More information about the MediaWiki-l mailing list