User:Razool/MultipleWiki

Scenario 3: Quick set-up
You want to install more than one wiki on a single server, using the same source code (i.e. single set of MediaWiki files), and using the same database?


 * 1) Install prerequisites.
 * 2) Upload MediaWiki files to web folder on the webserver.
 * 3) From browser, browse to the uploaded folder (for example, if your web server is running as   and MediaWiki files were uploaded to   folder, then the URL would be  ) which will lead to a page which gives a link to Please set up the wiki first. Click the link, fill-in the setup form, and install the first wiki (e.g., MyWiki). For details, see Manual:Config script.
 * 4) After successful installation, move LocalSettings.php into the root directory of your wiki and rename it in such a way to make it easy to track (e.g., myWikiLocalSettings.php)
 * 5) Repeat step three and four above for each wiki you wish to create, creating a new LocalSettings.php file for each wiki (e.g., anotherWikiLocalSettings.php, etc.)
 * 6) If two or more separately installed wikis are to be merged to operate out of files of the main wiki, then after renaming and moving each of your LocalSettings.php files to the main wiki folder, change the variable $wgScriptPath in the each of the LocalSettings.php files to point to the main wiki's folder.
 * 7) Create a LocalSettings.php file for your global settings, then select one from the two possibilities below:


 * 1: If you have different domains/subdomains that link to one directory on your server, use this:
 * To link your subdomains to one directory on your server, you may have to edit the configuration file for your server (can not be done with a  file, try changing   there in Apache web server setup) or, if your site has its own IP address, modify the DNS configuration for your site.


 * OR 2: If your wikis are in different directories (e.g.,   etc) linked to the main wiki directory on your server (say  ), use this:


 * If the function strpos finds the string you search for at the beginning of $callingurl, then the function returns 0 (i.e. it found the string starting at position zero) therefore, you need to change  to.


 * If you use Short URL with the second case (directory based wikis), you need to check the two directories:, to symlink the sources , and adapt.


 * You should use "srtpos == 1" or similar instead of plain strpos to avoid redirecting to wrong wiki when the url contains the name after the beginning

You can use a different unique MySQL database for each wiki (see $wgDBname) OR you can use a different table prefix for each wiki (for Postgres, you can achieve a similar effect by using different schemas) (see $wgDBprefix).

Scenario 6: Multiple wikis through RewriteRules
This approach is based on the work of Mizanur Rahman (see Boolean Dreams Article and it has elements in common with above. Follow steps 1-5 in  to setup the individual wikis. Then modify the LocalSettings.php file for each wiki along the lines:

Wiki 1 Local Settings File:

Similarly for Wiki 2 Local Settings File:

You'll also need a master file, along the lines described in step 7 of to choose the appropriate local settings file for wiki1 or wiki2 based on a url.

Finally, in the .htaccess file you need RewriteRules to map the article urls to standard wiki urls and non-article urls to the folder containing the wiki source. Assuming the wiki source is installed in '/w/', .htaccess would be something like:

Fix for Maintenance Scripts
Maintenance scripts run directly, not via a url so the RewriteRules won't provide a suitable url for the master LocalSettings.php file to $_SERVER["SERVER_NAME"] or $_SERVER['REQUEST_URI']. To work around this, use a separate global varible to offer an alternate selection method and define the variable on the command line when calling maintenance scripts. A suitable master LocalSettings.php would be something like:

Then, when running a maintenance script, such as importImages.php from the command line:

Here the -d switch modifies the auto_prepend_file setting in php.ini to execute a file before the importImages.php script. This file sets the global variable to select the wiki:

1
To get this to work, I had to use different values of $wgScriptPath for each wiki as I think Kai was suggesting AND create rewrite rules to map these to the single wiki source. So, in the individual LocalSettings files:

& in .htaccess with the wiki src in the directory /w/