Manual:Installing MediaWiki on Windows Server 2003

This guide shows how to install MediaWiki on a computer running Windows Server 2003. This also works on Windows XP Professional if Internet Information Services (IIS) is installed (see Control Panel, Add/Remove Programs, Add/Remove Windows Components).

The WIMP stack used for this installation:


 * Windows Server 2003
 * IIS 6
 * MySQL 4.1 (There are problems with MySQL 5.0.26 and higher as of Nov. 22, 2006)
 * I have MySQL5 and PHP5 running under Win2K Advanced Server SP4, no problem. I also have SMF 1.1RC3 working fine. - Slamlander 23:04, 25 November 2006 (UTC)


 * PHP 5.1.1

MediaWiki (latest stable version)
The latest stable release as of February 20, 2007 is MediaWiki 1.9.3

PHP 5.1.6
Latest version: 5.1.6 older version: PHP 4.3.12

MySQL-4.1
MySql 4.1

DBTools 3.03 (optional)

 * DBTools 3.03
 * MySQL db Administration

Note: These steps, with minor variations, were used to successfully install a system using Windows 2003 Server, MediaWiki 1.7.1, PHP 5.1.4 and MySQL 5.0.

Preparation:
Read all of the instructions first. Installing PHP 5 is not easy. [ Note: the 5.2.1 installer (msi) is cake. ]

PHP 5.x [Recommended]
NOTE: This section needs to be updated. The newest version of the php installer has an option to install the MySQL plugin automatically. all you have to do is edit your configuration file. -MLW

(MySQL is no longer built into PHP for Windows and so you must enable it manually)

;extension=php_mysql.dll Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\PHP] "IniFilePath"="C:\\php" - cgi.force_redirect = 0 Also make sure to copy libmysql.dll (from zip file) to the c:\php or iis will not find the php_mysql.dll (unable to load) upload_tmp_dir="c:\php\uploadtemp" session.save_path="c:\php\sessiondata" ENSURE IUSR_MACHINENAME has Read&Execute Permissions to C:\PHP\ext AS WELL AS libmysql.dll file, "access denied" type error will be encountered later on
 * 1) Download PHP 5.x installer and PHP 5.x zip package from php.net
 * 2) Run the installer
 * 3) Grant IUSR_MACHINENAME modify permissions to C:\PHP\uploadtemp
 * 4) Grant IUSR_MACHINENAME modify permissions to C:\PHP\sessiondata
 * 5) Open the zip package and extract the ext folder to your PHP root folder (default is C:\PHP)
 * 6) Put the PHP root folder and ext (default is c:\PHP and c:\PHP\ext) on the system PATH (instructions) system restart is required
 * 7) Open php.ini in your windows folder (default is C:\Windows or C:\WINNT) and uncomment this line:
 * Important: Make sure you specify this in your registry, or PHP will not recognize your php.ini file (i.e. when you look at phpinfo, the configuration file location is set to C:\WINDOWS instead of C:\PHP: **
 * Also, if the "cgi.force_redirect" line is present, ensure it is uncommented and set to 0. Otherwise you will get an error in your browser any time you try to access any PHP page.
 * Also, if you try logging in but it doesn't stay logged in when you goto the next page, then check to ensure the following are set correctly in your php.ini file.

''If you are using a machine on a domain etc and are having trouble finding the user IUSER_MACHINENAME (or IUSR_MACHINENAME, pls. substitute MACHINENAME by the name of your computer!) ''you need to change the Location for user lookup to be the localmachine (which is at the top of the tree when you click Locations).

If you want your wiki to be able to email you, after you've installed PHP then you'll also have install pear and download the pear modules mail and net_smtp. c: cd \php .\php pear\go-pear.bat pear install mail pear install net_smtp
 * 1) From Internet Explorer goto: http://go-pear.org
 * 2) Copy entire webpage, and paste into file: c:\php\pear\go-pear.bat
 * 3) From Command Line, do the following:

PHP 4.3.11
PATH=C:\PHP; (postpend to the paths already present!) PATHEXT: .PHP
 * use an msi and test that it has been loaded.
 * add it to the PATH and PATHEXT variables:

C:\>php -v PHP 4.3.11 (cgi-fcgi) (built: Mar 30 2005 17:34:09) Copyright (c) 1997-2004 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies


 * grant IUSR_MACHINENAME modify permissions to C:\PHP\uploadtemp
 * grant IUSR_MACHINENAME modify permissions to C:\PHP\sessiondata

For thumbnailing to work: ;extension=php_gd2.dll
 * Copy php_gd2.dll (or download here) from your php install folder, subfolder "extensions" (typically C:\php-4.3.11-Win32\extensions) to your windows system folder (c:\winnt\system32)
 * Open php.ini in your windows folder (%windir%) and at the very end, uncomment this line:

To enable email, you must also provide the name of a valid SMTP server: If the server running your wiki is not an SMTP server,
 * Open php.ini in your windows folder (%windir%), and under the [mail function] section change the line "SMTP = localhost", replacing "localhost" with the name of your SMTP s

2. Create a virtual directory

 * Extract the MediaWiki distribution into C:\wiki\mediawiki and, using IIS Manager, create a virtual directory (virdir) pointing to it. See http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/5adfcce1-030d-45b8-997c-bdbfa08ea459.mspx?mfr=true for IIS v6, see http://support.microsoft.com/kb/172138 for earlier IIS versions.
 * Grant the permissions Read and Execute to this virtual directory by opening the Properties for the virdir, selecting the "Virtual Directory" tab, and making sure both Read and **** are checked in the "Local path:" section.
 * Ensure that the virtual directory has the .php extension enabled. (Note: The PHP installation should have already configured this.)  To do this, select, right click on the web site with the virdir, select Properties.  In the resulting dialog, select the "Virtual Directory" tab, and finally click the "Configuration..." button.  In the "Application extensions" window, scroll down to verify .php is listed and the path to php-cgi.exe is correct.
 * Ensure the default document is set to index.php. To do this, select, right click the virdir and select Properties/  In the Properties window, select the "Documents" tab, and in the "Enable default content page" verify index.php is at the top of the list.
 * Finally one must change the Execute Permissions of the Virtual Directory "virdir". Go to the virdir properties > Virtual Directory Tab > In the Execute Permissions Drop Down Box, select Scripts and Executables. Click Apply, and OK

3. Configure IIS to allow PHP scripts to execute
Note that the menus mentioned in this section are not present on Windows XP Professional SP2. In that case, you may safely skip this step, as the restriction you would otherwise need to disable for PHP isn't present in the first place. In XP Pro SP2, there is no "Web Service Extensions" folder.

Within the "Internet Information Services (IIS) Manager" The system should allow you to have 2 extensions referencing the same Required Files (C:\PHP\php-cgi.exe), but in some cases people have reported this as something that doesn't work for them. There is no definitive fix for this at the time of this writing...other than to tell you that it works for me... Possible workaround is to copy php-cgi.exe to php-cgi2.exe and use php-cgi2.exe instead.
 * 1) Expand
 * 2) *(+) Internet Information Services
 * 3) **(+) Hostname <-- The name of your server
 * 4) ***(+) Web Service Extensions
 * 5) Right-click and choose "Add a new Web service extension..."
 * 6) In the new window entitled "New Web Service Extension":
 * 7) In the "Extension name:" field, enter, "cgi" (without the quotation marks)
 * 8) Then click "Add..."
 * 9) "In the new window entitled "Add file" and in the field "Path to file:", type in "C:\PHP\php-cgi.exe" (without the quotation marks)
 * 10) Click "OK"
 * 11) Tick "Set extension status to Allowed"
 * 12) Click "OK"

4. Install MySQL 4.1

 * Use the setup file. Perform a "Complete" installation with defaults.
 * Check the 'configure now' box and select 'detailed configuration'
 * Options to choose: Server, multifunction, OLTP, Latin1 collation, Enable TCP/IP Networking, Disable 'strict mode', add BIN to PATH variable, do not change accounts (mediawiki installation will gack) [NB this probably means mySQL will install with blank root password], start as a service
 * ensure the installation worked:

C:\>mysqlshow -u root -p Enter password: *********** +---+  | Databases | +---+  | mysql     | | test     | +---+

5. force MySQL to use 16-byte password encryption

 * open the file C:\Program Files\MySQL\MySQL Server 4.1\my.ini
 * add the following in the [mysqld] section:

#Use old password encryption method old-passwords


 * restart the MySQL service! (enter NET STOP mysql, then NET START mysql)

NB: the reasons for this are detailed at http://dev.mysql.com/doc/mysql/en/old-client.html

Also need to run the following commands:

C:\>mysql -u root -p Enter password: ***** -> UPDATE mysql.user SET Password = OLD_PASSWORD('new_password') [set this to whatever you want your root password to be] -> WHERE Host = 'localhost' AND User = 'root'; -> FLUSH PRIVILEGES;

6. Install MediaWiki by visiting the virdir previously created
NB: if your website cannot be addressed as localhost, then go to IIS setting, select the vroot and right click on it and select browse.


 * visit the virdir in a browser
 * sitename: demowiki
 * contact email: root@wikihost [whatever you want your contact email to be]


 * sysop: WikiSysop
 * pwd: S3cur3Passw0rD
 * no caching
 * MySQL SERVER: wikihost [or 'localhost']
 * dbname: wikidb
 * wikiuser S3cur3Passw0rD2
 * root pwd: S3cur3Passw0rD3 (just use whatever you set the root mySQL password to in step 6 above)

7. Create LocalSettings.php in root directory of mediawiki

 * After you visit http:// /config/index.php the following will be displayed on your browser. Copy everything between  to a file in a root directory of your wiki called: LocalSettings.php

Below is the start of that section:

Warning: fopen(LocalSettings.php): failed to open stream: Permission denied in C:\Inetpub\wwwroot\wmobilewiki\mediawiki-1.5.4\config\index.php on line 687 Couldn't write out LocalSettings.php. Check that the directory permissions are correct and that there isn't already a file of that name here... Here's the file that would have been written, try to paste it into place manually: <?php
 * 1) This file was automatically generated by the MediaWiki installer.
 * 2) If you make manual changes, please keep track in case you need to
 * 3) recreate them later.

$wgEnableUploads		= true; $wgUseImageResize		= true;
 * To enable image uploads, make sure the 'images' directory is writable, then uncomment this:
 * Also, to enable thumbnails, follow instructions above for php, then set this to true:

8. change the root password of the MySQL instance!
Use the command line or DBTools.

9. Fix the script error
If you are getting "Undefined index REQUEST_URI" error messages try this: This problem is a PHP for Windows problem. You should replace all references to the REQUEST_URI member of the _SERVER array with SCRIPT_NAME. The name of the same variable is different between the Windows and UNIX versions of PHP.

Thus: Old: $_SERVER['REQUEST_URI'] Change to: New: $_SERVER['SCRIPT_NAME']

I have seen this within:
 * "includes/Setup.php", lines 90, 96, 97
 * "includes/WebRequest.php", line 284
 * "includes/Skin.php" line 574
 * "includes/GlobalFunctions.php", line 232
 * "includes/wiki.php", line 388
 * "index.php", line 228
 * "includes/HttpFunctions.php", line 33 (MediaWiki 1.7.1)

Remark: You can also add $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME']; to LocalSettings.php

However, $_SERVER['SCRIPT_NAME'] isn't always equal to $_SERVER['REQUEST_URI'], especially when a rewrite module is employed and/or directory names are used instead of default file names. The only way to get 100% Apache-compliant $_SERVER['REQUEST_URI'] is to use the ISAPI Filter and steps listed here.

a. Fix Access to page when hosted on a Windows 2003 Domain Controller
If you host MediaWiki on a Windows 2003 server acting as a Domain Controller, you may receive an error message when trying to open the page. This is because the default domain controller security policy will prevent running of CGI scripts.

Try the solutions on Microsoft KB904056.
 * WARNING: Use a domain controller as a IIS host at your own risk. Any security breach could potentially lead to the attacker having access to your entire Active Directory database.
 * Note: First attempt Method 1: Set the CreateProcessAsUser metabase setting to false. This has been used successfully in multiple installations.

b. Fix Email problem when using IIS SMTP Relay / Exchange
If you are having problems getting email notifications working and receive and error message of Invalid Address 5.5.4 (when using MediaWiki 1.6.5) then you can edit includes/UserMailer.php around line 45:

Before: class MailAddress { /** 	 * @param mixed $address String with an email address, or a User object * @param string $name Human-readable name if a string address is given */ 	function MailAddress( $address, $name=null ) { if( is_object( $address ) && is_a( $address, 'User' ) ) { $this->address = $address->getEmail; $this->name = $address->getName; } else { $this->address = strval( $address ); $this->name = strval( $name ); } 	}

After: class MailAddress { /** 	 * @param mixed $address String with an email address, or a User object * @param string $name Human-readable name if a string address is given */ 	function MailAddress( $address, $name=null ) { #To get round IIS SMTP Invalid Address Problem $this->name = ""; if( is_object( $address ) && is_a( $address, 'User' ) ) { $this->address = $address->getEmail; } else { $this->address = strval( $address ); } 	}

c. Permission Denied issue on IIS (Windows XP)
Follow the steps of this article: http://www.ekhoury.com/2007/01/15/permission-denied-php-on-iis/

d. Other Problems?
(taken from Brion Vibber's post to the MediaWiki Listserv)

Confirmed that the installation was correct? Confirmed that the GRANTs on the database are correct? Confirmed that the username and password given to the installer are correct? Tried digging into the code to add more output checks? Checked the MySQL error logs?

If you are still having problems, ensure that you have done the following:

Tried fresh install? Tried different settings? Tried a different server? Tried different ports? Any difference between the multiple servers?

If you're having trouble with blank pages on IIS and can't switch, try the workaround suggested in this bug report: http://bugzilla.wikimedia.org/show_bug.cgi?id=1763

TODO: fix for --
 * 1) Turck MMCache not installed, can't use object caching functions

 documented by mailto:ian@library.du.edu ian 12:57, 24 May 2005 (Mountain Daylight Time) mailto:wiki@laurent.ca laurent 08:31, 07 November 2005 mailto:josh@coady.us joshcoady 11:54, 24 December 2005