Newcomers guide to installing on Windows

From Meta, a Wikimedia project coordination wiki
This is an archived version of this page, as edited by FT2 (talk | contribs) at 16:19, 25 December 2004. It may differ significantly from the current version.

Installing mediawiki on Linux and Unix is relatively straightforward. Installing on Windows is more complex.

  • Some packages are not ideally suited for Windows, or specidfic compilations are needed.
  • Instructions for some modules are not clear
  • Appropriate versions are not always clear
  • Some error messages are harder to trace in Windows than *nix

The following is a summary of windows installation, including some of the key config files and details.

Software used

  • Windows 2000 or XP
  • Apache v2.x (Tested with 2.0.52)
  • MySQL v4.0.x (Tested with 4.0.21)
  • PHP v5 (Tested with 5.0.1)
  • phpMyAdmin, used to monitor and manage MySQL (Tested with 2.6.0-pl3)
  • Turke Memcache (compiled for PHP 5.0.1, Windows)
  • ImageMagick (Still trying to get this one working)
  • Mediawiki (Tested with 1.4 beta 3)

Software issues and notes

All in one, or separates

I tried to use all in one's, like EasyPHP and Xampp. To be honest, I wasn't happy with either. There were a few reasons. EasyPHP has some out of date stuff (I want to use PHP5 on other pages), and xampp is fine if you dont want to customise it. But as each individual program is updated, its normal to want to run the latest stable versions, and an all-in-one ties you down a lot. So these instructions summarise installing "separates". Its harder, and slower, but more fulfilling and future-proof when done. Plus you don't have to wonder if you are running half the package or what has been left out, or tweaked.

Apache/php

I have seen warnings about apache/windows in a production environment, and about apache2/php5 not to be used together. The reason is mostly, Apache2 is a major rewrite and now uses multi-threaded code. But some multi-thread stuff isn't 100.00% fully tested yet in PHP5. It seems there has been some concern that some PHP5 extensions may not be 100.00% multi-thread robust. But its been a while now, and the main ones seem to be fine.

There is enough on Google to look up these issues, but at this point I can say, they seem to work together "as best as one could hope for". In other words, it works and it's "pretty stable", if you have a well installed system, I haven't seen any problems yet. If you get stability issues, or don't mind using apache 1.x, that would probably work too.

MySQL

I have memories of warnings about MySQL 4.1 as opposed to 4.0, but these may be out of date or minor. Someone will need to advise if these are important or not. They may not be.

Memcache

Memcache can speed up PHP by several hundred times, as it caches the results of compiled PHP code for future use. It's well worth using and mediawiki will advise if its up and running. But it needs to be specifically compiled for each version of PHP it seems. The stable version 2.4.6 is long due an update, there is a 2.6.7 in CVS, but if you search hard, you will find pre-compiled versions for Windows.

You will need to find a version compiled for the specific version of PHP you are using, alternatively you can compile it yourself, there are instructions on the web. The precompiled versions I found were at:

http://localfoo.info/modules/ipboard/index.php?showtopic=364&st=0

There appear to be a minor bug with memcache, namely it reports an error on shutting down apache2. But it doesn't seem to affect it in operation.

ImageMagick

This allows mediawiki ro perform magic with images. I have had some problems in figuring out whats needed, mostly due to lack of information. Things I have found:

  • There are different issues with versions < 6.0 and versions 6+
  • You need in addition to ImageMagick, a php extension to access its dll's, usually called php_imagick.dll. There are versions around of this.

The official source for this only has experimental support for ImageMagick v6+, so it may be worth sticking with a version 5.x if unsure.

  • It's not clear which of these needs to be compiled to match what, nor where and what files are needed. It could be simple, it may not, we'll see.

Mediawiki

There is apparently a bug in the current version's setup module. What should happen the first time you run mediawiki, is it should ask you to set up the wiki, then accept some basic info, set it up, create a LocalSettings.php file, and report success.

Version 1.39 didn't create the file, and reported a blank page. After asking round I tried a beta version of 1.4, which worked correctly.

Note that mediawiki assumes your MySQL amin account is called "root". If it isn't, you will need top temporarily ensure it is, to set up the wiki.

Installation

We set Apache, MySQL and PHP up first, then add other features.

Apache2

Straightforward. If you dont know your server or domain, just enter MY_SERVER and MY_DOMAIN, you can edit those in http.conf later. Install it as a service. Done.

MySQL

Also straightforward.

PHP5

You get two options here, a zipped binary version, or a .exe installer version. Go for the zipped version. Save it in a folder of your choice. You only need selected files out of it.

Special folders

Special folders include:

  1. A documents folder for apache to use as its root, for serving web pages. Create one, if you don't want to use the default.
  2. For MySQL, a data folder and a temporary folder. Put them where you like. You must copy the mysql folder from its default location if you change it, or MySQL will not be able to start.
  3. For phpMyAdmin and Mediawiki: both of these are PHP scripts. As far as Apache is concerned, they are nothing more than web pages being served. So you will want 2 folders in your web server folder, one called "\phpmyadmin" and one called "\wikiname" (a short name for a wiki, like \wiki2 or \mywiki). Just dump the entire phpmyadmin code into the first, and the entire mediawiki code into the second.
  4. For Memcache, create a folder it can use for temporary use.

Configuration

Configuration can get complex and messy. So this is in overview. A working copy of config for each of the programs is given below, to show a version which worked.

File and path names

Be aware most of these programs were initially developed for unix and linux. So in most cases you have to enter windows filenames with a / not a \. This is a very common problem. For example, the line to a file might be C:/PHP not C:\PHP in some config files.

  • Apache and MySQL use / instead of \ for paths, under windows.
  • PHP.INI uses \

All of these programs can handle spaces in file names.

Files you need to move into correct places

Config files can go in a variety of places. Ultimately I put php.ini and my.ini (MySQL) into the C:\WINDOWS system folder, and left the apache http.conf file where apache put it. You can tweak these using the Phpinidir parameter in apache2, by tweaking the system PATH, or in other ways. But this worked best and easiest for me in the end.

The files you need to move or copy are:

  • PHP CONFIG - php.ini into C:\WINDOWS. The version to start with is the "recommended" ini, if you look for it in the PHP folder.
  • PHP EXECUTABLES - move the following files into C:\WINDOWS as well: libmysql.dll, php5ts.dll, php.exe, php_mysql.dll. The two MYSQL files are needed for MYSQL functionality, the PHP5TS is the main PHP executable, and the PHP.EXE is for command line PHP to work if you ever need it. Any other PHP_ extensions you plan to use, put in the same folder.
  • MEMCACHE.DLL - put mmcache.dll into C:\WINDOWS too, when you find it. Its just another php extension.
  • MYSQL CONFIG - pick one of the my.ini files and put that in C:\WINDOWS too. There are several of them, the difference is mostly dependent on how powerful the server will be and how much resources you will give MYSQL. They're all mostly the same apart from that.
  • APACHE CONFIG - http.conf, held in Apache2\conf. Leave it there.

When you edit the config files, remember, most of these programs are extremely fussy about the contents of the config files. Always save a backup before editing, because it's almost guaranteed at some point you will get an error and need to revert to the previous version. If in doubt, take system restore points at key points where you feel you have got somewhere, and don't change so much at once that you forget what you've done.

MySQL setup

MySQL testing

Next, open a command prompt. With luck, the commands NET START MYSQL and NET STOP MYSQL should set the service running and kill it. If you get errors, look carefully at the edits you made, and the paths and files you have given.

Apache setup

All thats needed is to edit http.conf.

Main tasks:

  • Tell apache where to serve documents from
  • Add modules to access PHP ("php5apache2.dll")
  • Enable apache monitoring
  • Set the PHPIniDir (if you didn't put php.ini into C:\Windows)
  • Add a server and domain ID (if you didnt give one during install,and now want to)
  • Tell apache to serve files called index.php and other documents as HTML
  • Restrict what information apache gives out about itself
  • Set up aliases (eg MYDOMAIN/wiki --> your wiki folder)
  • Set up permissions (who can access and execute code in different folders)
  • Set up web page serving to allow monitoring and info viewing
  • Odds and ends - add descriptions, compression handling, server side images, localisation, etc, if desired.

See the example below for a sample of a working http.conf.

Note - I had a problem with DoocumentRoot and DirectoryIndex, solved by moving them further up the config file, above all the Directory and alias definitions. I dont know why this happened.

Apache testing

Note that apache loads PHP as a module. But we haven't configured or tested PHP yet. So comment out the line: LoadModule php5_module "L:/Program Files/Php/php5apache2.dll" for now.

Next, open a command prompt. With luck, the commands NET START APACHE2 and NET STOP APACHE2 should set the service running and kill it. If you get errors, look carefully at the edits you made, and the paths and files you have given. be carefiul - it is APACHE2 not just APACHE.



Firewall and windows issues

Apache uses port 80, and MySQL uses port 3306. You may not want MySQL to be externally accessible, but you will probably want apache to be. So you'll have to open your firewall for these programs. Good luck - it took me some time but I can confirm that it works!