How to Install Apache, PHP, and MySQL on Windows?

This article will teach you how to set up Apache HTTP Server, MySQL and PHP on the Windows operating system. To develop dynamic web pages these are a common set of applications used. For people who would like to learn the basics quickly so they can go explore on their own that’s the reason this tutorial series was developed. As with all tutorials, before following the instructions I recommend reading the whole tutorial.in

Apache HTTP Server is the web server that will be used to process all web requests. Static files such as images or basic html pages would be supplied. If Apache sees a request for a PHP file, it will pass the file to PHP. PHP will be used to process PHP code and create the dynamic web pages. MySQL is the database we will use to store and retrieve data.

First we have to decide which version of each application will be installed. To some degree, each version of PHP depends on a specific version of Apache. Since this is a beginning of the tutorial, to get you going I have already selected compatible versions. Here I choose the following 32-bit versions for you:

Apache 2.2.24, MySQL 5.6.11.0 & PHP 5.2.17

Installing and Testing Apache HTTP Server


Download the Apache Server from Apache Lounge:

http://www.apachelounge.com/download/win32/binaries/httpd-2.2.24-win32.zip


Unzip the server software

  1. Right click on the zip file and then click ‘extract all’
  2. The extracted Apache2 folder to must be moved to c:\


Configure Apache HTTP server by editing the configuration file

So you are now going to make some changes to the Apache configuration so that your web server is only accessible on your local system and not cannot be accessed to your local area network or the internet.

  1. First edit the file c:\Apache2\conf\httpd.conf
  2. Then on line 47, change ‘Listen 80′ to ‘Listen 127.0.0.1:80′
  3. Change ‘#ServerName www.example.com:55′ to ‘Server Name 127.0.0.1:80′ on line 173.
  4. After finishing the above steps save the file.


Starting the Apache HTTP Server

  1. Run ‘httpd.exe’ (this is the web server executable) which can be found in c:\Apache2\bin
  2. If httpd.exe fails with the error ‘MSVCR100.dll is missing’ you are missing some software the Apache depends on. Download the following and install it.
  1. Note: When you want to connect to your webserver this executable needs to be running.


Test your Apache HTTP Server installation

  1. In a web browser, browse to http://127.0.0.1
  2. You must see ‘It works!’ being served from the Apache server.


Installing MySQL Community Edition 32 bit


Download the MySQL installer.

  1. Browse to http://www.mysql.com/downloads/installer/5.6.html
  2. Here select the Windows (x86, 32-bit), MSI Installer


     3. Then the page will redirect you. Select ‘No thanks, just start my download.’

 

Install MySQL

  1. Run the mysql-installer-community-5.6.11.0 installer.
  2. You may be presented with a message about installing .NET Framework 4.0 after starting the installation,  If yes then install it from here http://go.microsoft.com/fwlink/?LinkId=181012
  3. Select “Install MySQL Products” when you make it to the welcome screen
  4. Then accept the license.
  5. After these steps their next window would be poorly designed it looks like two selectable radio buttons, but they aren’t. Just click ‘Execute’ and then the installer will make sure it has the latest data that it needs.



      6. You will select the type of installation next.

  • Just take note of where the default installation path and data path should be fine.
  • I decided to select the ‘custom install’ after some playing around.

NOTE: The default installation had some dependency issues on Excel so I choosed ‘custom install’. I don’t have any need for integration with Excel, nor will you if you are following my tutorials. So then you will have an opportunity to turn off after selecting next.

  • With the feature selection present, select ‘applications’, then uncheck ‘MySQL for Excel 1.1.1′ then select next.

  • You will then be presented with a dependency checklist of software that will be installed. Select ‘Execute’.

     7. Just click ‘Execute’ after the MySQL software installation list will be presented to you.

     8. Initial Configuration of ‘MySQL Server 5.6.11′

  • Check ‘Show Advanced Options’ after the default values are okay.
  • Config Type: ‘Development Machine’ is okay
  • ‘Enable TCP/IP Networking’ is checked or not
  • Check the ‘Show Advanced Options’
  • Then click ‘Next’   

     9. Account configuration

  • First set the root password (Make sure it is something you remember!)
  • Here you don’t need to create any user accounts right now.
  • Then click ‘Next’ 

     10. Windows service details

  • Pick a windows service name ‘MySQL36′ is okay
  • You must make sure that ‘run windows service as a standard system account’ is checked.

      11. Logging options

  • Default options must be used here.

       12. Finish configuration

       13. After setup start the MySQL Workbench

  • Then under ‘Open Connection double click the Local instance connection to Start.

 

 

  • You see the following screen if successful

 


Starting and Stopping MySQL

1. Run ‘net start MySQL36′ at the windows command line to start the MySQL service: Where MySQL36 is the name you chose in section 10.1

2. Run ‘net stop MySQL36′ to stop MySQL where MySQL36 is the name you chose in section 10.1


Installing and testing PHP


Download the thread safe PHP 5.2 windows installer.

http://windows.php.net/downloads/releases/php-5.2.17-Win32-VC6-x86.msi


Run the installer

  1. Run the installer that you just downloaded.
  2. Then accept the license.
  3. Select your installation location as: (C:\Program Files (x86)\PHP\)
  4. Then select the ‘Apache 2.2.x module’
  5. Here select the Apache configuration directory
  • Browse to (or enter in) c:\Apache2\conf\
  1. Under extensions, click on the Red X to change the following extensions to ‘Will be installed on local hard drive’

*MySQL

*PDO->MySQL

 

  1. That’s it finish installing PHP.

 

Fix the Apache configuration file.

Due to errors in the configuration file at this point httpd.exe will no longer run. This appears to be an error or a bug in the PHP installer. The configuration values are not been properly installed by PHP. Therefore you need to make httpd.conf point to the PHP installation.

 Then open c:\Apache2\conf\httpd.conf

Around line 496, point PHPIniDir and LoadModule to the correct location as seen below:

 1.PHPIniDir "c:/Program Files (x86)/PHP/"

 2.LoadModule php5_module "c:/Program Files (x86)/PHP/php5apache2_2.dll"

 


Create and run a PHP file

 

  1. Create the file named info.php in c:\Apache2\htdocs with the following contents

       <? php

       phpinfo();

      ?>

 2. Now, make sure that you start the Apache server by running httpd again. Do remember that, all the web requests come in to the Apache server, but the php files will be processed by the PHP software.

3. Test your PHP installation by browsing to
http://127.0.0.1/info.php
Here you should see a page that displays information about your PHP installation.

4. But what happened here? <?php starts a php block?> ends a php block. The phpinfo(); then call makes a call to a php library function and the output of the function is stuffed into the page that you receive.

If this knowledgebase tutorial created by Cloudcandy host was helpful to you, please let us know through e-mail, facebook or skype.

Was this answer helpful?

 Print this Article

Also Read

Have you changed or modified your customer’s FTP and FrontPage Passwords in Plesk?

We assume that you have already logged in to your Plesk control panel. Here let’s see how...

Auto CMS Installation

Hello,    We have automated CMS Installation at your Service, what you need to do...

PHP 5.6.0 Has Been Released With 10 New Features

PHP scripting language has released a new version that promises more performance and brings a...

Did you know what social engineering attacks is?

The art of manipulating people so they give up confidential information is known as Social...

Here are some important steps to Copy a MySQL table with phpMyAdmin

This article would help you with step-by-step procedure about how to copy a table with phpMyAdmin...

Powered by WHMCompleteSolution