WAMP, or installing Apache, MySQL & PHP on Windows Server 2003


Occasionally I get asked to do things that I don’t like to do. One of them is setting up a server with Windows Server 2003 on it. I’d much rather always go for the current operating system (e.g. Server 2008 R2) and if there is some incompatibility then we can work through it. One time this doesn’t apply is when you are setting up a server as a cold backup. This is a benefit of Software Assurance

For each Server License you have with Software Assurance, you have the right to install the same software product on a “cold” backup server for disaster recovery purposes

That means I can have one server waiting unplugged in server room to switch on if it’s twin server goes bang. I needed to build a replica of a particular web server in our company. It has to be exactly the same as the existing one because it is for Disaster Recovery only, therefore, no point in wasting a new licence. Yes the time may come when we have tested enough to get it on the most current OS but when that happens I’ll also update the cold backup.

So, on with the main part of this article. I have to install versions of Apache, MySQL and PHP on Windows (a.k.a. a WAMP server). The original server was set up by a person long gone from the company so it was a chance for me to try something new. I found the whole process really easy thanks to following the article » Beginners Guide: Install PHP 5, MySQL 5 on Apache 2.2 on Windows (with screenshots!) but there were a few tweaks and notes I had to do to get everything singing happily together. Below is the process I went through.

Windows

  • Install Windows Server 2003 R2 using the same license key as its “In Production” twin server
  • I am not going to install any roles on it as all services will be non-Microsoft ones
  • I have the operating system on the C: partition and will install all the web server bits on the D: partition.

Apache

  • Download the setup files
    • When downloading the setups choose the MSI option for easy installation (i.e. not the ZIP archive)
  • Apache.org use the Visual Studio 6 compiler (VC6) to build the binaries (setup.msi). However, this is incompatible with the latest versions of PHP.
    • The last VC6 compatible version of PHP is v5.2.17.
    • VC9 versions are compiled with the Visual Studio 2008 compiler and have improvements in performance and stability. The latest VC9 compatible version is PHPv5.3.6.
    • The VC9 versions require you to have the Microsoft 2008 C++ Runtime (x86) or the Microsoft 2008 C++ Runtime (x64) installed.
    • VC9 versions of Apache can be fetched at Apache Lounge but I was sticking to what we already used
  • The installation is very straightforward with no special instructions.
    • I set it to install to D:\apache
  • To test if Apache is installed properly just go to http://localhost in your web browser and you should get an “It Works!” message

PHP

  • Download the setup files
  • PHP needs to be the Thread Safe version. This is designed for web servers as opposed to apps.
  • I followed the guide mentioned above to check I was installing it all OK except
    • I installed it to D:\php
    • I added the MySQL and MySQLi extensions
  • Next you need to tell Apache where PHP is installed
    • Open d:\apache\conf\httpd.conf file in a text editor and look for the line near the bottom of the file
      • PHPIniDir “”
    • Put he path to the PHP install directory inside the quotes
      • e.g. PHPIniDir “d:\php\”
    • If you subsequently add any PHP extensions, via Windows setup, you will need to modify this line again as it gets reset to the default
  • Restart the Apache service
  • You can test if PHP is installed properly (and get loads of other potentially useful info) by creating an empty text file and adding the following code
    • <!--?php phpinfo();?-->
    • Save it as info.php in the d:\apache\htdocs
    • You can then easily access it by going to http:\\localhost\info.php in your web browser.
  • You can also quickly check what version of Apache and PHP you are using by looking at the Apache Status Monitorapache-service-monitor
    • MySQL Community Server

      • Download the setup files
      • This install is very customisable so I would recommend following the same guide as I did for the PHP part if you have no idea what you are doing!
        • I installed this to D:\mysql

      That got everything working. I left it in the hands of our fantastic web developers to copy over all of the important web site bits from the “live” server and test it was running identically. When that was done it was safe to shut it down and leave it waiting against the wall, like the unpopular kids at the prom.

      Future options

      I could have made this a virtual machine but I’m not sure how that effects licensing. One benefit this would have had is that I could still keep it up to date with all the latest Windows security patches via the Virtual Machine Servicing Tool

      If the time comes to update the server to Windows Server 2008 R2 I would probably scrap Apache and run PHP though IIS. I think that would be easier to manage and keep secure. Microsoft have made it super easy to get PHP installed through their Web Platform Installer and you can find a multitude of information at the official Microsoft php.iis.net website.

Advertisements

4 thoughts on “WAMP, or installing Apache, MySQL & PHP on Windows Server 2003

  1. IIS offers no mod_rewirte so for a professional SEO oriented website IIS is non-sense. Only way is to install a tools that offer similar function

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s