This guide is intended for beginners who wanted to install PHP 5 and MySQL Community version 5 and make it work with Apache 2.2 . Installation will be done locally, so that you can test web application such as Wordpress before going live. This is quite a long guide so prepare yourselves for a ride!
Prerequisites : You had already installed Apache 2.2 locally on Windows. If not, please read my previous Apache 2 installation guide and come back later to continue with this post.
Install PHP 5 on Windows
1- Download the latest Windows PHP Binaries (MSI file) from this page. I choose the eZNetworking mirror because it is the closest one to Malaysia. Choose a mirror that is nearer to your country for a faster file download. The latest PHP version that I downloaded is 5.2.4. Save the file to your Desktop.
2- Right click on the file and click “Install“.
3- Click “Next ” once the Welcome page is displayed.
4- Select “I accept the license agreement” and click “Next “.
5- Change your PHP installation path OR just accept the default path - C:\Program Files\PHP\ and click “Next “.
6- On the Web Server Setup screen, select the Apache 2.2.x Module and click “Next “.
7-On the Apache Configuration Directory screen, browse for the Apache configuration directory (conf) OR just enter C:\Program Files\Apache Software Foundation\Apache2.2\conf\ and click “Next ” to proceed with the installation.
8- For now, accept the default selection and click “Next”.
9-Click “Install ” to install PHP 5 on Windows.
10- Click “Finish ” once completed. PHP 5 is successfully installed.
11- Start your Apache 2.2 server using the “Monitor Apache Servers” console (Start -> Apache HTTP Servers 2.2.4 -> Monitor Apache Servers ). You can see that PHP was successfully installed by checking the Apache status at the bottom of the console.
Test your PHP 5 Installation
1- Open up your Windows Notepad. Type in “” inside the file. Save this file as “info.php” inside your Apache root directory, C:\Program Files\Apache Software Foundation\Apache2.2\htdocs .
2- Open up your web browser. In the address bar, type in your web server domain name plus info.php as the file name. Example: http://www.syahid.com/info.php . You should get a PHP configuration page just like the one below.
Congratulations! You have successfully installed and test PHP 5 on Windows!
Tell Apache 2.2.x to Support PHP Index File
What happens if you change your index.html (default web server homepage) to index.php and try to access your homepage? Apache will not recognize it and you won’t see anything displayed on the page. To make sure Apache recognizes index.php as a default homepage too, follow the instructions below.
1- Rename your index.html to index1.html and info.php to index.php (for testing purposes only!).
2- Edit your Apache configuration file, C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf by opening it with Windows Notepad.
3- Find a line that starts with “DirectoryIndex index.html…“. Add index.php at the end of the line . Save the file and restart your Apache Server from the “Monitor Apache Servers” console.
4- Load your Internet browser again. Type in your web server address e.g http://www.syahid.com. You should get a page similar to the info.php page above. Index.php now is recognized as a default Apache homepage, just like your normal index.html page.
Install MySQL 5.0 Community Edition on Windows
1- Download MySQL 5.0 Community Edition to your Desktop from here. If you want to download from a different mirror, click here. Make sure you always download the “Complete package “. Current version during this post was written is 5.0.45.
2- Unzip mysql-5.0.45-win32.zip (the downloaded mysql file) to get Setup.exe. Double click Setup.exe to start installing MySQL. Click “Next ” when you are prompted as below.
3- Select “Typical” for Setup Type and click “Next ” again.
4- Click “Install ” to proceed with the installation process.
5- The setup activity will show you some advertisement. Read it if you wish and click “Next “.
6- Tick “Configure the MySQL Server now” and click “Next ” two times.
7- Click “Standard Configuration” to ease installation process and click “Next ” again.
8- Tick “Install As Windows Service” to make MySQL auto-startup with Windows and “Include Bin Directory in Windows PATH ” to make MySQL system files automatically available for other application.
9- Tick “Modify Security Settings” and enter a root (Administrator) password to secure your MySQL installation. Don’t skip this step! Click “Next ” again.
10- Click “Execute” to start the MySQL Configuration process. Once finished, click “Finish ” to end configuration.
11- Make sure MySQL runs automatically after installation. You can check the status from Administrative Tools Services snap in (Start -> Programs -> Administrative Tools -> Services ), also available via Control Panel.
12- (OPTIONAL) Open your DOS command prompt (Run -> cud). Type in “net stat -na“. Check out ports opened by MySQL (3306) and Apache (80) . That means the services are up and running.
13- (OPTIONAL) Run some of MySQL commands to further ensure that the installation is a success. Check out and follow the commands as pictured below. User account is root and password depends on what you have entered previously during your MySQL configuration.
14- IMPORTANT: Reboot your machine! This is to ensure all MySQL system files are rss-read by Windows as environment variables.
Configure PHP 5 to Work with MySQL with MySQL PHP Extension
Previously, we have installed PHP with minimal modules / extension. To add MySQL support to PHP, you need to change your PHP installation - by adding the MySQL extension on top of your PHP installation. Please make sure that your original PHP 5 MSI installer still remains at its original place .
1- Open the Add / Remove Programs console via Windows Control Panel. Find the PHP 5.x.x entry and click “Change “.
2- Click “Next ” once you are prompted the Welcome page.
3- Click the “Change ” button to proceed.
4- Select Apache 2.2.x as shown in the picture below. Click “Next ” once again.
5- Select your Apache configuration directory (conf) - the directory where your httpd.conf resides. Click “Next ” once done.
6- On the “Choose items to install” screen, click on the plus (+) icon next to Extensions to expand the list.
7- Select on the “X” next to “MySQL” and select “Entire feature will be installed on local hard drive”. Click “Next” again.
8- Click the “Change” button to save all the PHP configuration changes.
9- Finally, restart your Apache 2.2 web server! You can check out that the MySQL extension support for PHP was successfully installed by checking out the info.php / index.php page that was created before.
Congratulations! Give yourself a pat on the back to finally manage it here. Now you can run almost many web applications that depends on Apache 2.2, PHP 5 with MySQL 5 database support. If any of those app complain about any missing extensions, remember that you can always reconfigure PHP by following the steps above.
Whew! This is quite a long guide but I really hope that someone out there will benefit from it!