Manual:Running MediaWiki on Windows

&lt; Running MediaWiki

This page will give you information about installing MediaWiki on a Microsoft Windows system.

You will need the following software:
 * Support software
 * DBMS: MySQL only option currently supported
 * Web Server: Apache or IIS
 * PHP
 * other utilities such as texvc
 * the Mediawiki code itself

You will also need some serious hardware for the full Wikipedia database, depending on how much demand it will require. Meta-wiki has some information on how many clients its clusters support, and their configuration, which can be used to gauge this.

Last, there is optional software which will help. This includes:


 * PHP optimising software (Zend Optimizer). Cleans up compiled PHP code to make it run 50-100% more efficiently.
 * PHP caching software (Turke Memcache). Saves the compiled PHP for future use, so it doesnt need to be recompiled, speeding up execution by 100x or so.
 * Image processing software (ImageMagick). Used for format conversion and thumbnails
 * Web page caching software (Squid). Used to store rendered pages for re-use.

Choosing a software installation method
MediaWiki is developed under a LAMP (Linux+Apache+MySQL+PHP) environment. It is recommended that you use as much of this stack as possible under Windows if you want MediaWiki to run smoothly. Therefore, IIS is not recommended. Instead, using the "AMP" portion of the "LAMP" stack is more likely to succeed.

Although these products are not that difficult to configure under Windows, it can be extremely difficult to install and configure Apache+MySQL+PHP one product at a time if completely new to apache/mysql/php. Under such circumstances it is highly recommended to look for a LAMP or WAMP pre-made combination which can just be installed and used. These will save you 99% of the trouble of configuring each package manually. The down-side is that some of these are trimmed down or modified versions which makes it hard to upgrade individual components, and other ones are seriously out of date.

You can install the support components individually, or all together as a package. A step by step guide to installing mediawiki with separate packages for Apache 2, mySQL 4 and PHP 5, on windows, can be found at Newcomers guide to installing on Windows. Some important information as of December 2004 to help select which software to use can be found in that article too, as well as a guide to issues and sample config files.

Currently, the best example of an up-to-date "all-in-one" package for Windows, is the Saint WAMP sourceforge. Others include:


 * Xampp
 * Uniform Server
 * IBServer (not recently updated?)
 * EasyPHP (not recently updated?)
 * FoxServ (not recently updated?)

See also: Wiki on a stick.

Here are the step by step instructions for installing MediaWiki under Windows using an all-in-one package. It is a 15 minutes process instead of my original 5 to 8 hour unsuccessful attempt using the separated installation method. I did the installation under Windows XP Professional, though it should work for Windows 2000 or similar releases.

Preparing Apache, MySQL and PHP

 * 1) Download your selected package. This example uses EasyPHP, but each will have its own install instructions, usually very simple.
 * 2) Stop or uninstall IIS from the Windows management tools if your machine already has IIS installed. Check "Control Panel->Performance and Maintenance->Administrative Tools->..." Is there an IIS icon? If not, you're done. If there is, stop the IIS service.
 * 3) Install your WAMP.  For EasyPHP that means:
 * 4) Double click the downloaded EasyPHP installation package under Windows to install it. Some of the screens of the install wizard may not be in English.
 * 5) Be sure to change the default installation path to C:\EasyPHP instead of C:\Program Files to avoid the space in path.
 * 6) Run EasyPHP from "Start->All Programs->EasyPHp1-7->EasyPHP".  A bold black "E" will appear as a mini task when EasyPHP is running.
 * 7) Change the interface language to English by double clicking the "E" icon after installation is complete. There is a select box on the lower part of the popup window where you can specify the language to use.
 * 8) Start Apache and MySQL (in EasyPHP that's from the same popup window)
 * 9) Go to http://localhost/ to test it

The Apache+MySQL+PHP+MysqlAdmin is all set! Isn't that easy?

For The Saint WAMP [TSW], install the package, also install the Documents plug-in. Run the Apache command from a command prompt to create a new .htpasswd file (as described in \TSW\readme.txt) and overwrite the existing password file (Apache2\conf) with this one. Then connect to localhost:3000, login, and you're pretty much done, one fully configured system ready to be wikified!

You may want to install Memcache if not already included in your WAMP, and ImageMagick or some other graphical manipulation package. Instructions, and links to some Windows builds, are also given in Newcomers guide to installing on Windows, and the php settings needed are shown in the sample php.ini.

Installing wikipedia
After successfully installing the underlying software, you can install wikipedia.

I got a blank page at this point using Mediawiki 1.3.9 on Windows XP Professional in Firefox 1.0. I reloaded the page (reposted forms data) and the LocalSettings.php file was created.
 * 1) Download MediaWiki from sourceforge file list or portal page
 * 2) Uncompress the MediaWiki source tree under C:\EasyPHP\www\mediawiki . I usually install WinRAR for each Windows machine I use. WinRAR can uncompress all common compressed file formats. Google on WinRAR for download sites. The Extractnow utility should also be able to handle this, and it's completely free (WinRAR requests a donation). (Actually Extractnow doesn't handle tarballs - try Stuffit.)
 * 3) Double check that the PHP source files are actually in C:\EasyPHP\www\mediawiki (or \TSW\Apache2\htdocs\mediawiki, if using TSW), not in a subdirectory underneath it.
 * 4) Make sure Apache and Mysql are on by double clicking EasyPhp's "E" icon.
 * 5) If you are using 1.3x, do the following:
 * 6) Edit /includes/DefaultSettings.php
 * 7) As the first variable declaration, insert $IP="{Actual Pathname of MediaWiki}" e.g $IP = "C:\\EasyPHP\\www\\mediawiki" (note the double backslashes)
 * 8) Change stylepath to $wgStylePath   = "$wgScriptPath/stylesheets";
 * 9) Remove all curly brackets inside strings - anything like "{$this}/foo" should be "$this/foo"
 * 10) Change logo path to $wgLogo= "$wgScriptPath/stylesheets/images/wiki.png";
 * 11) Access http://localhost/mediawiki and configure mediawiki as instructed by the page.
 * If you get a blank page at this point, and it has not created the "LocalSettings.php" file, this may be a software issue in the 1.3x series of mediawiki. Try using the latest stable or beta version 1.4x mediawiki instead.


 * 1) Move generated C:\EasyPHP\www\mediawiki\config\LocalSettings.php to C:\EasyPHP\www\mediawiki\ .  I.e. move it into its parent directory
 * 2) Enjoy your MediaWiki under Windows now: http://localhost/mediawiki

Tasks after installation:
 * Go to http://localhost/mysql/ to set root password for MySQL. Note that entering the trailing "/" matters!
 * Edit the file C:\EasyPHP\www\mediawiki\LocalSettings.php to configure your wiki.

MediaWiki
There are two options
 * the last stable release of the mediawiki software
 * the latest development version.

Stable release

 * go to http://sourceforge.net/projects/wikipedia/
 * press Download on the left of "MediaWiki stable release"
 * Save on your disk and extract it to c:\easyphp\www\mediawiki\

Latest release and CVS versions
Often as well as the stable version, there will be a beta of the next version. There may also be an "up to the minute" latest in CVS, not yet released.

These are development versions of MediaWiki and include the latest changes made by the developers. They may work well, or may have serious problems (of any kind, trivial through to major data corruption), so be careful about using a beta or CVS version. Generally use the stable version unless you need the development version to work around a bug you can't avoid, or to gain some key feature or compatibility with latest software, or resolve other issues. Always check the release notes if unsure. If you aren't familiar with computing and don't like to test the latest software, get the stable release.

You can download all versions (stable and development) from CVS, sourceforge, or following links in this meta-wiki. If you want to grab a CVS version ("up to the minute" software) and do not already have a CVS client, you will have to get one and install it. WinCvs is a suitable CVS software for windows and can be found at http://www.wincvs.org. Get MediaWiki from the CVS archives.

Installing
Visit your wiki with a web browser and follow the install directions! :) (Go to /config/index.php from the directory where you installed MediaWiki)

not sure how well the following applies

PHP does not handle the include_once directive properly on all windows platforms and filesystems, probably due to the Windows treatment of upper and lower case in file names. You may have to comment out the include_onces in some of the .php files in the folder "includes" as follows:

Article.php:	# include_once( "CacheManager.php" ); Setup.php:	# include_once( "$IP/Title.php" ); SpecialMovepage.php:	#include_once( "LinksUpdate.php" );

Alternatively ensure that all inclusions use the same format i.e. make occurrences of ("CacheManager.php") and ( "$IP/CacheManager.php")'' consistent by using only one or other format. (I think the problem is because using the different formats is interpreted as two separate includes Mintguy 03:41, 22 Nov 2003 (UTC)).

When running IIS, if image uploading does not work, open SpecialUpload.php in the "includes" directory and change the text "if ( ! move_uploaded_file( $wpUploadTempName, $wgSavedFile ) ) {" to "if ( ! copy( $wpUploadTempName, $wgSavedFile ) ) {" This may be a PHP bug, but it got image uploads to work. Harbenger 08:09, 3 May 2004 (GMT-4).

iconv
Also, you really do need iconv for some of the special pages to work, unless you comment out the relevant call in language.php:

# return iconv( "UTF-8", $wgInputEncoding, $s );


 * Q:Did you try the iconv hack?
 * A:I believe there's a win32 build of iconv available out there somewhere!
 * Try looking at http://in2.php.net/iconv for more info! and a Win32 working (??) version is available at http://www.zlatkovic.com/pub/libxml/iconv-1.9.1.win32.zip

Note: If you are using PHP5, iconv is built in, I beleive that no extension is required.

Content
All the articles of Wikipedia and their revisions are available for download at http://download.wikipedia.org/ in a MySQL dump format. The cur dump is enough for reading / mirroring wikipedia. \progra~1\mysql\bin\mysql -u root -p mysql> use wikidb Database changed mysql> mysql> source c:\temp\20031104_cur_table.sql
 * the cur dump only holds the latest modification of an article
 * the old dump has all the earlier revisions
 * Save and extract the file somewhere (ex c:\temp\).
 * Open a command box (start -> run -> cmd.exe).
 * Execute:
 * Enter root password for mysql
 * At the prompt select the wikipedia database (this is, by default, named 'wikidb'):
 * Then load the dump (change filename by the filename you downloaded):

N.B. this will take some time (several hours) if you load the full dump of the English Wikipedia database!

Database Management System
''The only DBMS currently supported is MySQL. Further instructions will be added as other options become available.''

The download link below points to a page with all available versions of MySQL. The one you want is "Production release" which is recommended.

While downloading, read the Install Guide using the second link below.
 * Download
 * Install Guide

Warning: the password hashing schemes are different between MySQL versions 4.0 and 4.1, and prebuilt binaries of PHP use the MySQL 4.0 client. Therefore it is recommended to use MySQL 4.0.x to run your MediaWiki, otherwise you will have problems when installing.

Apache
Install the Apache web server from http://www.apache.org/ using the latest 2.x binaries. Use the Download link below, select a mirror close to your location and download the "Win32 Binary (MSI Installer)" version. Currently this is version 2.0.50 (sep. 2004)
 * Download
 * Install Guide

Configuration

Change the httpd.conf file for apache. It should be located at "C:\Program Files\Apache Group\Apache2\conf" if you used the default installation: LoadModule php4_module {PATH TO YOUR PHP FOLDER}/sapi/php4apache2.dll AddType application/x-httpd-php .php AddType application/x-httpd-php .php .php4 .phtml AddType application/x-httpd-php-source .phps php_admin_flag engine off  php_admin_flag engine on    
 * Add these lines at the end of the block of LoadModule lines:
 * Change the DocumentRoot
 * Add the PHP types and disable PHP for all directories other than the wiki


 * Note: if you need PHP for other purposes, you will need to add other directory sections like that above. Do not enable the PHP engine by default.
 * It is not strictly necessary to enable the rewrite engine or include the ampersand patch
 * You will have to change c:/playpen/wiki/runtime/wiki to your script directory. Copy all the executable PHP files for MediaWiki into this directory.

IIS
If you are using MediaWiki with IIS, after generating LocalSettings.php I believe you need to edit the setting for $wgArticlePath, changing it from: $wgArticlePath = "$wgScript/$1"; To: $wgArticlePath = "$wgScript?title=$1";

If you don't do this, you will get "no such file or directory" errors if you try to view any page such as "/index.php/Main_Page".

PHP
Install PHP from http://www.php.net/ using the latest windows binaries using the Zip package. Latest version 4.3.8.
 * Download
 * Install Guide
 * Documentation in several langages

I found that you needed to copy php4ts.dll (or php5ts.dll for PHP5) to the windows/system32 directory in order for Apache to load php4apache2.dll Imran 08:59, 27 Apr 2004 (UTC)
 * There is also the option of copying php4ts.dll to the directory which contains php4apache2.dll - Jeronim 14:32, 21 Jul 2004 (UTC)

You will need to enable the GD library to use the thumbnailling pictures. Note that if using ImageMagick, the path contained in wgImageMagickConvertCommand cannot have spaces.

ImageMagick
The "Q8" ImageMagick releases use 8 bits per channel, while the "Q16" releases use 16 bits per channel. In order to make image thumbnailing work, you will need to open includes/Image.php, locate the line that starts with, and remove the escapeshellarg function so that the end of this line looks like:

Texvc
texvc</tt> is the external program MediaWiki uses to render math expressions into nice looking PNG. Getting it up and running on Windows can be somewhat troublesome, as it was developed on and for linux, so here is a quick and dirty hack to make it work under Windows.

What you'll need:
 * the texvc</tt> sources (included in the math directory of the MediaWiki distribution)
 * a Make utility (for example mingw32-make, included in MinGW)
 * an OCaml compiler
 * Latex and dvips (for example using the Miktex package for Windows)
 * ImageMagick binaries for windows

First modify render.ml</tt> to reflect specificities of the windows platform: let cmd_dvips tmpprefix = "dvips -R -E " ^ tmpprefix ^ ".dvi -f" let cmd_latex tmpprefix = "latex " ^ tmpprefix ^ ".tex >/dev/null" let cmd_convert finalpath = "convert -quality 100 -density 120 ps:- " ^ finalpath ^ " >/dev/null 2>/dev/null" becomes: let cmd_dvips tmpprefix = "dvips -R -E -q \"" ^ tmpprefix ^ ".dvi\" -f >\"" ^tmpprefix^".ps\" " let cmd_latex tmpprefix = "latex -quiet \"" ^ tmpprefix ^ ".tex\" >\""^tmpprefix^".tmp\" " let cmd_convert finalpath tmpprefix = "convert -quality 100 -density 120 \"ps:"^tmpprefix^".ps\" \"" ^ finalpath ^ "\" " because Windows doesn't handle /dev/null nor pipes very gracefully, and as the quiet option doesn't work on latex for Windows.

As this creates more temporary files, you have to delete them too: Sys.remove (tmpprefix ^ ".dvi"); Sys.remove (tmpprefix ^ ".aux"); Sys.remove (tmpprefix ^ ".log"); Sys.remove (tmpprefix ^ ".tex") becomes: Sys.remove (tmpprefix ^ ".dvi"); Sys.remove (tmpprefix ^ ".aux"); Sys.remove (tmpprefix ^ ".log"); Sys.remove (tmpprefix ^ ".tex"); Sys.remove (tmpprefix ^ ".ps"); Sys.remove (tmpprefix ^ ".tmp")

And finally, split the call to dvips</tt> and convert</tt> in two: else if (Sys.command ((cmd_dvips tmpprefix) ^ " | " ^ (cmd_convert (finalpath^"/"^md5^".png"))) != 0) then (unlink_all ; raise (ExternalCommandFailure ("dvips"))) becomes: else if ( (Sys.command (cmd_dvips tmpprefix)!=0  )) then (unlink_all ; raise (ExternalCommandFailure ("dvips"))) else if (Sys.command (cmd_convert (finalpath^"/"^md5^".png") tmpprefix)!=0) then (unlink_all ; raise (ExternalCommandFailure ("dvips")))

If you have Visual C++ and MASM installed, make the optimized texvc.exe</tt> by running the make utility in the math directory. If you do not have Visual C++ and MASM, make the bytecode version texvc.bc</tt> (by typing for example mingw32-make texvc.bc</tt> in the math directory) and rename it to texvc.exe</tt>. Copy the executable into your base MediaWiki directory.

In /includes/Math.php</tt> replace the following: wfDebug( "TeX: $cmd" ); by the following: $cmd=str_replace("'","\"",$cmd); wfDebug( "TeX: $cmd" ); because in Windows single quotes do not work as quote markers in command line. And comment the following: if( !is_executable( $wgTexvc ) ) { 				return $this->_error( "math_notexvc" ); 			} becomes /*if( !is_executable( $wgTexvc ) ) { 				return $this->_error( "math_notexvc" ); 			}*/ because windows can't find the is_executable function.

In LocalSettings.php</tt>, uncomment or insert: $wgUseTeX= true; to activate texvc functionality.

If you are using MediaWiki with IIS then you should replace "REQUEST_URI" with "SCRIPT_NAME" in all files.

And finally, set the texvc</tt> executable path to the root path of Wiki, by inserting this line in LocalSettings.php</tt>: $wgTexvc = "texvc"; # Location of the texvc binary

Let me know how this works for you in the discussion page.

Next page: Running MediaWiki on Mac OS X >