MediaWiki on IIS

Author: Eric Woersching

Published on January 14, 2008 by ewoersch

Updated on April 09, 2009 by ewoersch

Average Rating  Rate It (0)

RSS

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. 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>
  2. 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:

Related Content

Comments

  1. Submitted on Oct 17 2008 by
    runpin
    there are some mistakes, i think.
    all images uploaded can't show when i clicked them.
  2. Submitted on Dec 16 2008 by
    david.s
    Hi,

    This setup did not work for me, I finally traced it to a problem with the PHP realpath() function used by MediaWiki. I've posted on the forums - http://forums.iis.net/t/1153823.aspx

    realpath('.') is reporting the path to the PHP executable rather than to the file being called. Any assistance appreciated!
  3. Submitted on Apr 04 2009 by
    ljamal
    I was able to install MediaWiki and I'm using the clean URLs.
    However, I ran into a problem with the special pages and any page containing a colon (:). As long as clean URLs are being used, the URLs with colons are rejeced by URLScan. Is there away around this?

    You can see an example of what I'm speaking of by visiting http://wiki.warmageddon.com/MediaWiki/index.php?title=Main_Page&action=history and clicking on the contribs link or the About link at the bottom.

    However, it's obvious that clean URLs work correctly since http://wiki.warmageddon.com/MediaWiki/Main_Page works without error.

    Any assistance would be a godsend.
  4. Submitted on Aug 06 2009 by
    Predated
    The clean URL solution above needs to be changed. In your web.config file, you'll need to change 2 lines from what was written above.

    After rule name="MediaWiki" is the match url line, change this line from:
    match url="^(.*)$" /.

    to:

    match url="^(.+)$" ignoreCase="false" /

    In addition, the rewrite action line must be adjusted. The line you need to change is write after the closing conditions line (/conditions).

    it should read
    action type="Rewrite" url="index.php?title={R:1}" appendQueryStrin="true" /
  5. Submitted on Aug 30 2009 by
    andrewdoull
    I've run into http 500 errors using the Windows Platform Installer version of the PHP install that I wanted to highlight the resolution to here for other people referencing this link. The issue is caused by the fact on at least the installation I've worked with, the IUSR account isn't a member of IIS_IUSRS and consequently the permissions changes you recommend don't work. I'm not sure whether this is an artifact of the build process I'm using (which involves NewSID), but it appears to be common enough to be worth mentioning. See http://www.mwusers.com/forums/showthread.php?t=11156 for details.

You must Log In to comment.