Manually install and check Apache, PHP, MySQL on Windows

If you want to do web development on your local PC or laptop you may use a development environment like WAMP (Windows equivelent of Linux LAMP) or XAMPP. However if you want to match your development environment to that of the actual webserver where your site will be hosted, you may want to manually install each of the components.

It is important to check if the build of Apache, PHP and MySQL matches your operating system (64 bit or 32 bit) as well as the VC++ version (VC14, VC11, VC10 etc) . You can check the VC++ version on your computer from Control Panel → Programs. You may install the required VC++ redistributable from Microsoft Developer tools website

Install Apache

Download Apache binary zip file from Apache Lounge. Extract to a folder of your choice.

The latest version at the time of writing this article is Apache 2.4 VC14 which is built with the latest Visual Studio C++ 2015. The previous VC11, VC10 builds are listed on the left.

In my example I am using 64-bit VC11 binaries

Apache 2.4.18 Win64 VC11 zip file is named httpd-2.4.18-x64-vc11.zip

Download and extract to C:\Apache24 or your preferred location, say, C:\Myfolder\Apache24

Configure Apache

Find conf directory inside the folder where Apache is installed Eg: C:\Myfolder\Apache24\conf

Open the file httpd.conf with a text editor.

Edit the file to point SRVROOT to directory where Apache is installed.

Define SRVROOT "c:/Myfolder/Apache24"
DocumentRoot "c:/Myfolder/Apache24/htdocs"

Note: The format of http.conf file is slightly different on different versions of Apache.

Run and Verify Apache

Open a command prompt and navigate to bin folder inside Apache24 and run command httpd

C:\Myfolder\Apache24\bin> httpd 

If there are errors in the httpd.conf file these will show up with corresponding line numbers. If you see just a blinking cursor that means the command was successful and HTTP server was launched. Minimize the command window, do not close it, because closing will terminate the server session.

Open a web browser and go to http://localhost/

You should be able to see the default welcome page.

Install PHP

Download the PHP binary of required version from PHP for Windows Download page

Go for the Thread Safe version because Non Thread Safe does not have Apache DLL. In this example I used PHP 5.6 VC11 Thread Safe 64-bit php-5.6.17-Win32-VC11-x64.zip.

Download and extract to your preferred location Eg: C:\Myfolder\php

Copy php.ini-development to php.ini

Go to Apache conf directory and edit httpd.conf to add the following lines at the end.

LoadModule php5_module "c:/Myfolder/php/php5apache2_4.dll" 
AddType application/x-httpd-php .php
PHPIniDir C:/Myfolder/php

Restart Apache. Press ^Z at the command window that was used to launch httpd. Issue the command httpd to start HTTP server again.

Again if the configuration is wrong it will throw error messages. If you just see a blinking cursor then configuration was successful and HTTP server has been launched.

Test PHP

Make a new file called test.php in your document root folder. In my case, C:\Myfolder\Apache24\htdocs\test.php and inside the file put the following code:

<?php
phpinfo();
?>

Open a web browser and go to http://localhost/test.php

If you see a page with your PHP version and details then the isntallation was successfull.

Install MySQL

Download the msi installer from the MySQL downloads page

This installer will install MySQL and all its dependencies. I used MySQL Installer 5.6 for Windows. You will be prompted for basic configuration. Do set a root password that you will remember because you will need it later to login to the database.

Verify MySQL

Go to the folder where MySQL is installed and inside the bin directory.

C:\Myfolder\MySQL\MySQL Server 5.6\bin> mysqlshow -u root -p
Enter password: ********
+--------------------+
|     Databases      |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sakila             |
| test               |
| world              |
+--------------------+

Your development environment is ready.


Post a comment

Name

Your Comment

Email (We dont publish it)

Comments

Nothing yet..be the first to share wisdom.