Installing Apache and PHP on Windows

A few years ago, I installed a complete Apache / PHP / MySQL server and the process took 20 minutes.  It has just taken over 2 days.  Checking on-line forums, I don’t seem to be alone.  A common problem is an error message when starting the Apache service: “The requested operation has failed.”

The problem seems to by that there are numerous versions of Apache and PHP.  Most combinations of them are incompatible with each other.  Support does not seem to have been kept remotely up to date and the documentation is terrible.  Vital information is missing and in places it seems to be inaccurate.  This paper describes what worked mid 2013.

Apache

The latest Apache version is 2.4.  This does not appear to be supported by PHP.

Also, the documentation recommends using Windows Installer (msi) downloads, and these do not seem to be provided for Apache 2.4.  It seems the legacy version 2.2 has to be used.  Most versions of Apache 2.2 seem to work with Windows XP, but only the later ones with Windows 7.  Version 2.2.25 gave no trouble with Windows 7.  I used the download file httpd-2.2.25-win32-x86-no_ssl.msi.

The PHP documentation (http://windows.php.net/download/#php-5.5) says use the downloads from Apache Lounge.  This does not seem to work as there are no msi files from Apache Lounge.  I ignored the documentation and used the files from http://httpd.apache.org/download.cgi.   It worked.

PHP

The PHP manual says use Windows Installer for PHP 5.2 and later.  The latest version with an msi file is 5.3.27.  That is probably the best to use.

Now the real fun.  Only the thread safe versions of PHP support Apache and the documentation fails to say that.  If in the installer, you do not see Apache in the list of web servers, it is because you downloaded the non-thread safe installer.

The Install Process

The good news is that if you have downloaded the right files, the installation is a dream.  Just run the msi files (Apache first) and answer the questions – usually choosing the default options.  If it doesn’t work, it’s most likely a version problem.

If it Goes Wrong

Uninstalling Apache and PHP should be straightforward, but I found a version of Apache without an uninstall process.  To remove Apache manually you have to do the following:

  • Open the Apache monitor and stop the service.
  • Open the Windows Task Manager.  From the Processes tab, locate the Apache service and end it.
  • Delete the Apache directory structure.
  • Open Control Panel > Administrative Tools > Services and locate the Apache service.  Note its name.
  • Open a Windows Command Prompt and remove the Apache service by typing:

        sc delete e.g. sc delete Apache2.4.

  • Refresh the list of services and check the service has gone.

I hope this helps.  I’m afraid I’m not really able to help much more than this.

Facebook: The Software Marketing Expert.

Advertisements

3 thoughts on “Installing Apache and PHP on Windows

  1. A great help John! I got stuck by downloading the Non-thread safe PHP, didn’t see Apache in the list. Most confusing. And again – why no installer for 5.4+
    Oddly, many help sites recommend not using Thread Safe because its still considered experimental. Thanks for taking the effort to document, set me right in moments!

Leave a Reply

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 )

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s