MediaWiki on IIS

By Eric Woersching

January 14, 2008

Introduction

The following sections describe how to install and configure MediaWiki for use with FastCGI on Windows Server® 2008. This document assumes that you have completed the setup and configuration of the FastCGI extension and PHP libraries as described here.

The instructions have been tested and found to work in the following configuration:

  • Windows Server 2008 RC0
  • IIS 7.0
  • PHP 5.2.4 Non-thread-safe Win32 binaries (RC2-dev)
  • MySQL 5.0
  • Wikimedia 1.11.0

Notes on PHP Setup

1. Change the default session, upload folders and grant access to the built-in IIS_IUSRS group.
2. Open a Command Prompt window with administrator privileges and run the following commands:
cd /d C:\php (i.e. the location of your php root directory)
md session
md uploadicacls session /grant BUILTIN\IIS_IUSRS:(OI)(CI)(M)icacls upload /grant BUILTIN\IIS_IUSRS:(OI)(CI)(M)From the base configuration file provided by PHP, you will need to modify your php.ini to have the following definitions:  
upload_tmp_dir="C:\php\upload" 
session.save_path = "C:\php\session"

3. Enable PHP support for MySQL. Modify your php.ini to define the extensions directory and uncomment the PHP MySQL extension definition:

extension_dir = "C:\php\ext" (i.e. the location of your php extensions directory)
extension=php_mysql.dll

Download and Unpack MediaWiki

The latest release of MediaWiki is found at http://www.mediawiki.org/wiki/Download/. The instructions in this document are based on version 1.11.0, but future versions are likely to be very similar as far as installation is concerned.

1. After downloading the GNU zip package, extract its contents to %SystemDrive%\Inetpub\wwwroot\MediaWiki or another directory of your choosing.
2. M
odify the permissions for the MediaWiki config folder and grant Write permissions for the built-in IIS_IUSRS group.
3. Open a Command Prompt window with administrator privileges and run the following command:
icacls %SystemDrive%\Inetpub\wwwroot\MediaWiki\config /grant BUILTIN\IIS_IUSRS:(W)

Configure MediaWiki

1. Begin the graphical MediaWiki installation procedure by pointing your browser at http://localhost/mediawiki/config/index.php. You see the following screen.

2. Scroll down the window and configure your Wiki name and all the required fields. In the Database config section, enable the 'Use superuser account' checkbox and enter the database superuser password.

3. Once you enter all the required information, click "Install MediaWiki!". The configuration page creates the database wikidb and saves your settings in the %SystemDrive%\Inetpub\wwwroot\MediaWiki\config\LocalSettings.php file.

4. Move the LocalSetting.php file to the %SystemDrive%\Inetpub\wwwroot\MediaWiki\ folder and delete the folder %SystemDrive%\Inetpub\wwwroot\MediaWiki\config from your system.
5. LocalSetting.php contains sensitive information, so secure it by revoking access to unnecessary identities. Open a Command Prompt window with administrator privileges and run the following command:

cacls %SystemDrive%\inetpub\wwwroot\MediaWiki\LocalSettings.php /sddl:"D:PAI(A;;FA;;;SY)(A;;FA;;;BA)(A;;FA;;;NS)"

The previous command grants access only to the following identities:

SYSTEM

BUILTIN\Administrators group

Network Service

6. The installation is complete. Point your browser to http://localhost/mediawiki/config/index.php.

Testing the Application

For testing MediaWiki, create a user and modify the Main Page content.

1. Navigate to http://localhost/MediaWiki/index.php.

2. Click the Log in / create account link in the top right corner.

3. Click the "Create an account" link.

4. Enter the username and password and click "Create account".

5. Go to the main page and click the Edit link. An Editor displays in which you can make your changes. When done with changes, click "Save Page".


Here is the modified page.

Enabling clean URLs with URL Rewrite Module

When hosting MediaWiki on IIS 7.0, it is possible to configure MediaWiki to use URLs without query string by following these steps:

  1. Install Microsoft URL Rewrite Module for IIS 7.0
  2. Create a web.config file in the same folder where MediaWiki files were installed and paste into it the following
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
    <system.webServer>
    <rewrite>
    <rules>
    <rule name="MediaWiki">
    <match url="^(.*)$" />
    <conditions>
    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    </conditions>
    <action type="Rewrite" url="index.php?title={R:1}" />
    </rule>
    </rules>
    </rewrite>
    </system.webServer>
    </configuration>
  3. Update the LocalSettings.php file as follows:
    ## The URL base path to the directory containing the wiki;
    ## defaults for all runtime URL paths are based off of this.
    ## For more information on customizing the URLs please see:
    ## http://www.mediawiki.org/wiki/Manual:Short_URL
    $wgScriptPath = "/MediaWiki";
    $wgScriptExtension = ".php";
    $wgArticlePath = "${wgScriptPath}/$1";

Getting More Information

To discuss the FastCGI support in IIS, or file bug reports, use the FastCGI forums:

To get more information regarding running various PHP applications on IIS, refer to: