Open main menu

lensowiki β

Help:Running MediaWiki on Windows

Revision as of 05:34, 19 July 2006 by Wadmin (talk | contribs) (1 revision(s))

 

Running MediaWiki
This page is in need of serious help. You can edit it to improve the situation. OR you can see Installing MediaWiki on Windows Server 2003 SP1 for accurate instructions.


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


Software requirements and options

Required software

  • Support software
    • DBMS: MySQL the only option currently supported
    • Web Server: Apache or IIS
    • PHP
  • Mediawiki – the code itself

Optional utilities

  • Texvc (needed for rendering Math formulas)
  • PHP optimising software (Zend Optimizer). Cleans up compiled PHP code to make it run 50-100% more efficiently.
  • PHP caching software (Turke Memcache or eAccelerator). Saves the compiled PHP for future use, so it doesn't need to be recompiled, speeding up execution by 100x or so.

eAccelerator Windows binaries

  • Image processing software (ImageMagick or GD). Used for format conversion and thumbnails
  • Web page caching software (Squid). Used to store rendered pages for re-use.

Hardware

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.

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 DeveloperSide.NET Web-Server Suite and the Saint WAMP sourceforge. Others include:

See also: Wiki on a stick.

Installing Apache, PHP and MySQL as a Package

Choose a package to download from the list above. Step-by-step instructions are provided for Saint WAMP (ver 3.4), and EasyPHP (ver 1.8). Saint is the more up to date of the two packages, however EasyPHP is quite a bit simpler to use.

Internet Information Services (IIS) Manager Installed

If IIS is installed then there are some considerations. By default IIS and Apache both use port 80, so IIS will need to be uninstalled, disabled or moved to another port.

NOTE: Saint WAMP allows the default port for apache to be changed during the install. If you plan to keep IIS on port 80 and run Apache on a different port then IIS can be left as is.

To change the port IIS runs on:

  1. Open IIS Manager [Start -> Administrative Tools -> Internet Information Services (IIS) Manager]
  2. Expand Web Sites, right-click on Default Web Site and select Properties
  3. On the Web Site Tab change the Port field (example: 8080)
  4. Click OK
  5. Stop then start IIS to make the change come into effect


Installing Saint WAMP

  1. Run the downloaded Saint WAMP installation package
  2. Choose Classic WAMP for the install type
  3. Use the default install directory or change it as required
  4. The global options can be left as is, you may need to change the port if you are running IIS
  5. Python and SSL can be unchecked as they will not be used. Status could be useful.
  6. Select the mysqld-nt.exe service as it is optimized for the windows environments
  7. Start the Apache Monitor
  8. Start the TSW-Contentserver (use the Apache icon on the task bar)

Once Installed an administration account needs to be created

  1. Open a Command Prompt [Start -> Run -> Type 'cmd' -> OK]
  2. Type cd "\Program Files\TSW\Apache2\bin"
  3. Type htpasswd -cmd .htpasswd newusername
  4. Enter a new password twice
  5. Type copy .htpasswd ..\conf
  6. Type y to confirm replacing the file
  7. Go to http://localhost/ to test it
  8. Check out http://localhost:3000. When prompted use the user account created earlier.

After all this process, open the Window that displays all the services running on your computer (use the Apache icon on the task bar). Check if the TSW-MySQL service is running. If not, start it (right-click -> Start).

Installing EasyPHP

  1. Run the downloaded EasyPHP installation package
  2. Use the default install directory or change as required
  3. When the install finishs wait, two dialogue boxes should appear on top of the final install screen
  4. Click OK on the 'Mise a jour' box.
  5. The EasyPHP Dialogue box should show Apache and SQL already started
  6. Go to http://localhost/ to test it

Tasks after installation:

Configure Apache

The Document Root for Apache should be changed to point somewhere else, preferably on a separate volume. Create a new folder (i.e. D:\www) and then edit the Apache configuration file as follows:

  • First, open the httpd.conf file in the .\apache\conf directory
  • Then search for DocumentRoot and edit it
DocumentRoot "D:\www"
  • Finally, scroll down and change the '<Directory>' tag to be the same as DocumentRoot (if you installed the Saint WAMP distribution, change the '<Directory htdocs>' tag)
<Directory "D:\www">

You need to restart TSW-Contentserver for the changes to take effect.

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 MediaWiki

After successfully installing the underlying software, you can install MediaWiki.

  1. Download MediaWiki from sourceforge file list or portal page
  2. Uncompress the MediaWiki source tree under the Apache Document Root (Example. D:\www\Mediawiki)
  3. Access http://localhost/mediawiki and configure mediawiki as instructed by the page.
    In case you have difficulty accessing the database, you might need to do this in mysql:
    set password for 'root'@'localhost' = password ('new-password');
    If you get a blank page at this point, and it has not created the "LocalSettings.php" file, please contact someone for assistance (either on one of the IRC channels or mailing lists). Sometimes, just hitting Reload in your browser may solve the problem.
    If you installed it by hand, you may see this:
    Warning: dl() [function.dl]: Not supported in multithreaded Web servers - use extension=mysql.so in your php.ini in {path_to_htdocs}\wiki\install-utils.inc on line 17
    Could not load MySQL driver! Please compile php --with-mysql or install the mysql.so module.
    This means that you have forgotten to configure PHP to use MySQL. Please see your manual or install.txt (under PHP) on how to do this.
  4. Move generated .\mediawiki\config\LocalSettings.php to .\mediawiki\, I.e. move it into its parent directory
  5. Enjoy your MediaWiki under Windows now: http://localhost/mediawiki

MediaWiki

There are two options

  • Last stable release of the mediawiki software
  • Latest development version.

Stable release

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)

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).

Notable differences in Windows' LocalSettings.php

Windows file paths in php are different than *nix style paths.

For example on linux you may have:

$IP = "/var/www/apache2-default/wiki";

But on windows this is:

$IP = "D:\\Program Files\\Apache Group\\Apache2\\htdocs\\mediawiki-1.5.6";
Install diff3, file, and imagemagick (see below).

diff3 and file are available as parts of the gnuwin32 sourceforge project. (google "diff3 windows" and "file windows") Then you will replace

$wgDiff3 = "/usr/bin/diff3";

with

$wgDiff3 = "D:/Program Files/GnuWin32/bin/diff3.exe";
note: you also need to change the source that calls diff to not escape shell argument... Read on more.

and replace:

$wgMimeDetectorCommand= "file.exe -bi"; #use external mime detector (linux)

with

$wgMimeDetectorCommand= "D:/Program Files/GnuWin32/bin/file.exe -bi"; #use external mime detector 
note: you also need to change the source that calls file.exe to not escape shell argument... Read on more.

Content

For each wiki three sets of page data are produced as dumps in XML format. The download site shows the status of each dump, if it's in progress, when it was last dumped, etc. With mwdumper these dumps can be filtering and converting to produce output as another XML dump as well as SQL statements for inserting data directly into a database in MediaWiki's 1.4 or 1.5 schema.

See more: Data dumps

Support software information

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.

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.54 (june 2005)

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:

  • Add these lines at the end of the block of LoadModule lines:
    LoadModule php4_module {PATH TO YOUR PHP FOLDER}/sapi/php4apache2.dll
    AddType application/x-httpd-php .php
  • Change the DocumentRoot
  • Add the PHP types and disable PHP for all directories other than the wiki
    AddType application/x-httpd-php .php .php4 .phtml
    AddType application/x-httpd-php-source .phps
    php_admin_flag engine off
    <Directory "c:/playpen/wiki/runtime/wiki">
    php_admin_flag engine on
    </Directory>
  • 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". This is caused by the fact that PHP is installed in CGI mode by default.

In case you need to use the standard $wgArticlePath you would need to instruct IIS to run PHP in isapi mode. This can be easily done by changing the mapping of PHP from:

 path_to_PHP\php-cgi.exe

To:

path_to_PHP\php5isapi.dll

Under IIS 5: right click on the wiki application/properties/configuration/app mappings/edit the .php mapping.

An alternative would be using URL Rewriting in IIS as described in URL rewrite in IIS

In any case, with or without URL rewriting, the recommendation is to use ISAPI mode as pages will be served at much higher speed than in CGI mode.

PHP

Install PHP from http://www.php.net/ using the latest windows binaries using the Zip package. Latest version 5.0.4.

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)
Many packages (eg, XAMPP) handle this. Using one of these makes installation smooth. (Personal expieriance) --Astronouth7303 01:04, 31 May 2005 (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

Note: PHP now comes with GD enabled by default. This will work for thumbnailing, and will not require any configuration of modification.

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 $cmd = $wgImageMagickConvertCommand ., and remove the escapeshellarg() function, then do the same to the next line, so that the command variable builds like this:

$cmd  =  $wgImageMagickConvertCommand .
      " -quality 85 -background white -geometry {$width} ".
      ($this->imagePath) . " " .
      ($thumbPath);

In addition, check to be sure that the $wgImageMagickConvertCommand in localsettings.php points to
(your imagemagick folder path)/convert.exe - note the .exe-extension! It won't work, if ommitted.

Another way to make this work is to add the ImageMagick path to your Windows PATH variable, and simply setting the $wgImageMagickConvertCommand in localsettings.php as follows (note that you must still modify Image.php as shown above):

$wgImageMagickConvertCommand = "convert.exe";

Make sure that the Internet Guest Account (Usually IUSR_MACHINENAME) has Read & Execute rights to the ImageMagick bin directory. Without this you might see an PHP shell execution error similar to what happens when it can't find the convert.exe file.

Texvc

texvc 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.

Note: texvc is strictly optional. Your wiki will run fine without it.

What you'll need:

  • the texvc 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)
  • GhostScript for its Postscript libraries ([1]) (Caution! in newer versions the gswin32c.exe hast to be renamed to gs.exe)
  • ImageMagick binaries for windows

If you want to skip the OCaml compilation process you can use one of the following precompiled binaries:

You can skip the 'Building texvc section', but you will still need to make the edits to Math.php, LocalSettings.php described below. Also the installation of GhostScript, MikTex and ImageMagick is mandatory.

In any case - check, if the commands gs, latex, dvips and convert (not the built-in windows-tool!) are running. If not - put the paths to these Programs in the Path-Variable of Windows.

Building texvc on Windows

First modify render.ml 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 tmpprefix finalpath = "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.

Be careful since Windows XP also uses a program called "convert" !! (to convert partitions from FAT to NTFS) One way to avoid the problem is to change "convert" to something else linking to the right convert binaries. (this can easily be done under Cygwin by typing "ln -s /bin/convert /bin/<somename>")

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 and convert 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")))

NOTE: For windows, you should use "\" not "/" to split the path. So, you should change

let tmpprefix = (tmppath^"/"^tmpprefix0) in

to

let tmpprefix = (tmppath^"\\"^tmpprefix0) in

and change

else if (Sys.command (cmd_convert tmpprefix (finalpath^"/"^md5^".png")) != 0)

to

else if (Sys.command (cmd_convert tmpprefix (finalpath^"\\"^md5^".png")) != 0)

If you encounter this problem: (PNG conversion failed; check for correct installation of latex, dvips, gs, and convert – please try it!)

The final render.ml looks like the following:

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 tmpprefix finalpath = "convert -quality 100 -density 120 \"ps:"^tmpprefix^".ps\" \""^finalpath^"\""

exception ExternalCommandFailure of string

let render tmppath finalpath outtex md5 =
    let tmpprefix0 = (string_of_int (Unix.getpid ()))^"_"^md5 in
    let tmpprefix = (tmppath^"\\"^tmpprefix0) in
    let unlink_all () =
      begin
        Sys.remove (tmpprefix ^ ".dvi"); 
        Sys.remove (tmpprefix ^ ".aux");
        Sys.remove (tmpprefix ^ ".log");
        Sys.remove (tmpprefix ^ ".tex");
        Sys.remove (tmpprefix ^ ".ps");
        Sys.remove (tmpprefix ^ ".tmp");
      end in
    let f = (Util.open_out_unless_exists (tmpprefix ^ ".tex")) in
      begin
	output_string f (Texutil.get_preface ());
	output_string f outtex;
	output_string f (Texutil.get_footer ());
	close_out f;
	if Util.run_in_other_directory tmppath (cmd_latex tmpprefix0) != 0
	then (unlink_all (); raise (ExternalCommandFailure "latex"))
	else if (Sys.command (cmd_dvips tmpprefix) != 0)
	then (unlink_all (); raise (ExternalCommandFailure "dvips"))
	else if (Sys.command (cmd_convert tmpprefix (finalpath^"\\"^md5^".png")) != 0)
	then (unlink_all (); raise (ExternalCommandFailure "convert"))
	else unlink_all ()
end


If you have Visual C++ and MASM installed, make the optimized texvc.exe by running the make utility in the math directory. If you do not have Visual C++ and MASM, make the bytecode version texvc.bc (by typing for example mingw32-make texvc.bc in the math directory) and rename it to texvc.exe.

Configuring Mediawiki to use texvc

1. Copy the texvc executable into your base MediaWiki directory.

2. In /includes/Math.php replace the following:

wfDebug( "TeX: $cmd" );
with the following:
$cmd=str_replace("'","\"",$cmd);
wfDebug( "TeX: $cmd" );

(Note: my source, version 1.5.5, is slightly different: the wfDebug line is:

wfDebug("TeX: $cmd\n");

I don't know whether remove the \n or not when modifying this file )

because in Windows single quotes do not work as quote markers in command line

3 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. As of PHP 5.0.0, the is_executable function also exists under Windows environments.

(Again, I've noticed some differences; the piece of code above is, in 1.5.5, the next one:

if( function_exists( 'is_executable' ) && !is_executable( $wgTexvc ) ) {
				return $this->_error( "math_notexvc" );
			}

so, again, I don't know whether comment it or not! Looks as I shouldn't, since the first test in the if clause checks if the is_executable function is available... )

In LocalSettings.php, 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 executable path to the root path of Wiki, by inserting this line in LocalSettings.php:

$wgTexvc = "texvc.exe"; # Location of the texvc binary

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

Another way to use math under windows

Maybe you will find that compile texvc is so complicated. (I am the one.) Here is another solution (Using LatexRender, thanks to Benjamin Zeiss).

1. You must replace the content of math.php file with this at first.

2. Append follow content at the end of LocalSettings.php:

$wgUseTeX			= true;

#Where is your ImageMagick
$wgImageMagickConvertCommand	= 'D:\WebServer\ImageMagick\convert.exe';
$wgImageMagickIdentifyCommand	= 'D:\WebServer\ImageMagick\identify.exe';

#Where is your Tex
$wgLaTexCommand			= 'latex.exe';
$wgDvipsCommand		= 'dvips.exe';

3. Create folder "math" and "tmp" in the "images" folder if not exist.

4. Make sure you have a working ImageMagick, Gs854w32 and Latex.

5. Now you can try in the sandbox to see whether it works.

Next page: Running MediaWiki on Mac OS X >