How To: Install Apache 2.4, PHP 5.5 and MySQL 5.5 on Windows 8.1

By Austin M ·

It has lately been a gruelling time for us, meeting deadlines and really working hard to get out of that comfort zone that us developers usually find ourselves in. All in all, we thank God for the unrelenting grace!

In this article, I will show you how to manually install Apache 2.4, PHP 5.5 and MySQL 5.5 on Windows 8.1 (64bit) without using any ready-to-use packages like XAMP or WAMP.

So let’s get started;

What You Will Need

Apache: Since Apache does not offer binary packages for Windows, they also provide links to other third-party websites that provide the binaries here. Download Apache 2.4 binaries from apachelounge.com. Make sure to download the version that is relevant to your operating system’s architecture. If your OS is 32-Bit, you can download the 32-Bit Apache. For my case, I downloaded the 64-Bit version.

You can download the Apache 2.4 binary here.

PHP: Download the PHP binaries from the PHP for Windows website, specifically, the thread safe version. This helps PHP run as an Apache module, more info here. Choose the one that matches with your OS i.e. 32-Bit or 64-Bit.

You can download the PHP 5.5 binary here.

MySQL: Download the MySQL 5.5 installer from the MySQL website download page. Select the appropriate version depending on your system (32-Bit or 64-Bit). If you are running on 64-Bit, you can download it here.

Visual C++ Redistributable: This installs C++ libraries on a computer that does not have Visual C++ installed. The libraries are required to run Apache 2.4. Download Visual C++ Redistributable for Visual 2012 available here.

Installation

Apache

Install the Visual C++ Redistributable for Visual 2012 that we have already downloaded to enable you start httpd.exe (if not installed, you will get an error dialog stating that “MSVCR110.DLL” is missing in your system)

Extract the “Apache24” folder to the root of your hard drive. Your path should look like “C:\Apache24”

Update the httpd.conf file located at “C:\Apache24\conf\httpd.conf” as follows;

  • Around line 37, the ServerRoot variable should be updated to the correct root directory to your Apache installation like so;
ServerRoot “C:/Apache24/"
  • Around line 58 of the httpd.conf file, you should have “Listen 80”. This allows you to bind Apache to listen to specific IP addresses or ports. You might also get an error if your 80 and 443 port is being utilized by Skype or any other application. You should be able to start Apache without issues.
  • Around line 209, change the ServerAdmin address to what you prefer. This is where your users with problems and issues with your server or any applications running in the server will be emailed to.
ServerAdmin <[email protected]>
  • Around line 218, state the ServerName address to either your system’s hostname or localhost.
ServerName
  • Both lines 242 and 243 specify the directory where your documents will be served.
DocumentRoot <path to your root www directory>

Start Apache

  • Open a command prompt window
  • Type “cd …/…/Apache24/bin/” (without the quotes) then press Enter key.
  • Type “httpd.exe” then Enter key.
  • Navigate your browser to http://localhost. You should see a message “It Works!” if everything is setup correctly.

PHP

Installing PHP is similar to the process we have gone through on installing Apache. Extract the PHP folder to the root of your drive. So your PHP path should be something like “C:\PHP”

Locate and rename php.ini-development to php.ini

Update php.ini with the following;

  • Search for extension_dir = “ext” to include the path to the PHP module extensions (Around line 718). The path should be like;
extension_dir=”C:\PHP\ext”
  • Uncomment the dynamic DLL extensions that you will need (Around line 860)
  • Set up your time zone. You can get the list of supported time zones supported by PHP here (http://php.net/manual/en/timezones.php) I have mine set to;
date.timezone = Africa/Nairobi

MySQL

Install MySQL with the installer to the root directory of your hard drive and follow the steps. Your MySQL path should be something like “C:\MySQL” Once everything is correctly installed, the installer will prompt if you need to proceed with the configurations.

Remember to add an exception on the windows firewall to prevent blocking remote connections. Set an appropriate password to block or allow incoming connections from other machines in the network.

Link Apache with PHP

In order to configure the Apache to use PHP, add the following lines at the end of the httpd.conf file;

PHPIniDir “C:\PHP”
 LoadModule php5_module “C:\ PHP\php5apache2_4.dll”
 AddType application/x-httpd-php .php

Install Apache as a Windows Service

For your Apache server to run automatically when your system starts, you will need to install Apache as a windows service. With administrative privileges, access the command prompt and type the following;

  • Type “cd …/…/Apache24/bin/” (without the quotes) then press Enter key.
  • Type httpd.exe –k install then Enter key.

You should get the message “The Apache2.4 service is successfully installed”

You can now control the Apache service just like the other installed windows services on the Services window (Win + R then type “services.msc” then press Enter).

Time to Test-Drive!

To test our installation, we will use a PHP file with the following code inside;

<?
phpinfo();
?>

Save the file as “phptest.php” and upload it to you root web directory, for instance “C:\Apache24\htdocs”. Go to http://localhost/phptest.php. You should see all the info about your system and PHP modules installed. If you get an “Internal Server Error” or “HTTP Error 404”, something did not go right with your installation. Otherwise, that’s pretty it!

I hope this post has been helpful enough, lengthy as it is though. Now let’s commit to kicking butt!