Beginners Guide: Install PHP 5, MySQL 5 on Apache 2.2 on Windows (with screenshots!)
September 10, 2007 – 11:38 amThis 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 “<?php phpinfo(); ?>” 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!
Tags: apache, web server, php, apache 2, php 5, programming, system administration, mysql, mysql 5
Love this post? You may want to subscribe to my RSS feed. Thanks for visiting!













109 Responses to “Beginners Guide: Install PHP 5, MySQL 5 on Apache 2.2 on Windows (with screenshots!)”
I am very thankful to you. This technique is really very good.
By Bhaskar Rabha on Sep 19, 2007
By TechMalaya on Sep 19, 2007
WOW!!! Thanks after spending hours and hours of trying to install all 3 of these programs I finally decided to look up a tutorial, and this was it, THANKS!!!
By Brody on Sep 20, 2007
By TechMalaya on Sep 20, 2007
simply useful… thanks!
By jojo on Sep 22, 2007
By TechMalaya on Sep 22, 2007
Thanks for dropping by my blog :DThis tut is long, I recommend my tut unless you want to boost your techie ego: install wordpress locally
By TechZilo on Sep 22, 2007
By TechMalaya on Sep 22, 2007
man, after wasting 4 hrs, your pages helped me a lot. thanks a lot. Cagatay
By cagatay on Sep 23, 2007
By TechMalaya on Sep 23, 2007
I followed the instructions to install Apache with PHP. It works, but when I change the location of the DocumentRoot in httpd.conf and the Directory to match it, the PHP stops working in the browser, although it seems to be running Ok the the Apache Service Monitor.
By Tuyre on Sep 24, 2007
By TechMalaya on Sep 24, 2007
I have a problem. Everything is fine but I insert data to form and click submit it doesn’t show anything:
{{
Name:
Age:
}}
second page:
{{
“;
print “You are “. $Age . ” years old”;
print “”;
$old = 25 + $Age;
print “In 25 years you will be ” . $old . ” years old”;
?>
}}
By Suuri on Sep 25, 2007
By TechMalaya on Sep 25, 2007
Thank you so much for your tutorial! Got me out of a tight bind! Was using a book i bought, but discovered it was advising based on completely outdated versions which were impossible to even find, and the instructions weren’t totally relevant to new versions. Yours was perfect! Thanks again!
One question though, I do get the MySql data on the phpinfo test, but i tried another one using really basic stuff;
and it came up not connecting. anything obvious wrong?
Thanks again!
By Paul on Oct 14, 2007
The code didn’t seem to show up, this is it again anyway;
(no space)
By Paul on Oct 14, 2007
$connection = mysql_connect( “www.horan.com”, “root”, ” ” )
or die( “Sorry - unable to connect to MySql”);
echo( “Congratulations - You have connected to MySQL!” );
By Paul on Oct 14, 2007
By TechMalaya on Oct 19, 2007
This great….thanksss
By Andrie on Nov 9, 2007
10x for the guide it`s realy helpful.
i could`t solve that problem for week.
By Ivaylo on Nov 19, 2007
By Syahid Ali on Nov 19, 2007
Dude this is a greate tutorial , Just like a lot of people out there , iwould like to thank you . Though Ihad installed everything , there were some small configurations that was needed . Thanks to You i can get my Job done .
May god bless you.
By Siddharth on Nov 26, 2007
Hi,
Thankyou very much for helping me by giving clear information regarding installation procedure for PHP & Apache.
Regards,
Prasad
By Durga Prasad on Dec 6, 2007
Thank for the clear explanation and a updated guide!
By john smith on Jan 14, 2008
By Syahid Ali on Jan 14, 2008
Phew! After trying several times and searching everywhere find out how to install Apache, PHP5 and MySQL, I finally came across this tutorial.
I followed your precise instructions and they all installed the first time of trying, thank you very much for taking your time and effort to explain.
The instructions here are far better and clearer than the programmes own development site.
By Alan on Feb 4, 2008
By Syahid A. on Feb 4, 2008
Fantastic guide - thanks so much for it! Best one on the net!
By Tanner on Feb 5, 2008
Thanks! Your tutorial is the only one that got MySQL to work for me!
By Zac on Feb 5, 2008
By Syahid A. on Feb 5, 2008
Dear Friend,
I am trying to install PHP MySQL since 15 days but unable to install. At last I find your tutorial and atarted installing. Every thing is fine put I am not able to connect MySQL since pass word not matching. Please help me. Really I appreciate your very good tutorials.
By Sadiq Ali on Feb 16, 2008
By Syahid A. on Feb 16, 2008
Dear Syahid,
First of all, please accept my sincere thanks for your tutorial for beginners. Its really appreciable work. but i got stuck with mySQL installation at the end ie., setting password. am being warned “Error Nr.2003 Can’t connect to MySQL server on localhost(10061)”! I tried somany times by re-installing. Ooops!! no use. will you please help why it so happening? is the password what we use at the time of logging in to windows? if so, i set that password only!! hope you help me!!!
Thanks in advance!
By Error Nr.2003 Can't connect to MySQL server on localhost(10061) on Mar 1, 2008
By Syahid A. on Mar 1, 2008
Hello.
Thank you for this tutorial. It did help me but I stuck at one point.
I installed Apache 2.28 followed by PHP 5.2.5 and followed your tutorial for testing the installation.
I could get the webserver running.
I followed the Test your PHP 5 Installation section in this tutorial but I could not get the PHP configuration page on my browser.
What could be the problem?
Thanks.
By Lope Ben on Mar 4, 2008
By Syahid A. on Mar 4, 2008
Thanks Syahid A.
I got a blank page, and i did type the correct code correctly. But i was able to resolve it anyhow lately, by changing the foward slashes (/) of the directory paths that are auto generated by the apache config file to backslash(\) which is used normally in windows.
thanks
By Lope Ben on Mar 6, 2008
I have done all the above and I am using http://:88/info.php
I have configured apache on 88. Apache is working fine I have tested it. But php is not working.
Can someone suggest what could be missing?
Thanks!
By shashi on Mar 7, 2008
By Syahid A. on Mar 7, 2008
Hi,
TQ for the incredibly helpful guide. I have successfully installed Apache 2.2.8, PHP 5.2.4 and MySQL on my desktop yesterday. It is working indeed. TQ!
But today, when I try to install them on my laptop, i got 404 error when i want to test php on my local server. I’ve checked the code and the path.. a few times, and i think there’s nothing wrong there. PHP appreared on Apache monitor console, but phpinfo is not displayed. Is there anything wrong with my laptop then? My desktop is a DELL on dual core processor and my laptop is an ACER on AMD Turion.
By enesus on Mar 10, 2008
By Syahid A. on Mar 10, 2008
Wow, this is a great help! Am in the design stage for php and mysql features and this info is going to make it much much easier. Thanks for your wonderful information!
By Ellen on Mar 12, 2008
By Syahid A. on Mar 12, 2008
hi , First please accept my bigggg thanks for such a wonderful tutorial for beginners on apache installation ,php and mysql. I have done everything right but as mentioned in step 9 of “Configure PHP 5 to Work with MySQL with MySQL PHP Extension” i do not get MySQL page when I type in http:localhost/index.php…instead i get the php index page.please help
By srikanth on Mar 13, 2008
Dear Syahid,
Today i tapped my back after installing Appachi, PHP and MySql by sincerely following your instructions. Really yar your tutorial is excellent. I am not a computer wizard I learned computers only by reading by books and sincerely following the advices of people like you. Keep it up Syahid, really people like you are very helpful to make the people to learn computers. I was fedup with other tutorials but your stuff is really good. Now I request you to tap your back because you made a lay man to install PHP, Apache and Mysql.
Thank you once again.
By Sadiq Ali on Mar 14, 2008
I have done everything according to your NICE tutorial but I cant get “MySQL” section showing up running the info.php (pt. 9).
Same problem as srikanth (Mar 13, 2008) I belive.
Thank you in advance!
By Gnevi on Mar 14, 2008
By Syahid A. on Mar 14, 2008
Many many thanks - you’ve started me on the road to building my site.
I had tried to do this before from a well known book which gives you several screenshots of steps where the only available option is to click ‘next’, but only gives advice such as ‘enter all pertinent network information’ when you really need help! Your guide by comparison is very thorough and well-written.
Thanks again
By Matt Sim on Mar 19, 2008
Fantastic tutorial!! From M’sia? Me too!! Haha… I’ve been suffering for months because my WinXP Home Edition doesn’t have IIS and it’s difficult to test .asp file locally. Moreover, my MS Access seems to hate me, didn’t work properly. So is kind of giving up on MS and now trying hard to switch everything to PHP, Apache and MySQL… Really thanks for your tutorial, can’t find better tutorial than this on the net. Good job!!
By Chai on Mar 21, 2008
By Syahid A. on Mar 23, 2008
@Gnevi
libmysql.dll already comes with PHP. You just need to set the path in environment variables for windows xp.
1. Click start > Control Panel > System
2. Click the Advanced tab > Environment Variables
3. Under System Variables, highlight PATH then click edit.
4. Add ‘;C:\Program Files\PHP’ (assuming you used the default installation.
By Poldo on Mar 25, 2008
hi… thanks a lot for a detailed tut… It really helped me a lot when i was cornered!! Thanks dude
By Ujjwala on Mar 27, 2008
This was amazing. I was trying to get this to work for some time now quite unsuccessfully, but thanks to your guide i did it in 30 mins.
Thanks a lot!
By buzz on Apr 5, 2008
where do I load this file
mysql-5.0.45-win32
in which folder
By Siva on Apr 10, 2008
By Syahid A. on Apr 10, 2008
Hi
I wish i can express my feelings for your help because i had been trying to setup A.P.M ennviournment almost from one month you got a very great technic and explained welled now i have every thing to learn PHP Thanks alot
Allah/God give me you more knowledge and you will get every success
bye
By Syed on Apr 15, 2008
By Syahid A. on Apr 15, 2008
how do the apache 2.2 work on Local Area Network with an DHCP connection through Linksys Router
By Jun on Apr 16, 2008
thanks
By Jun on Apr 16, 2008
By Syahid A. on Apr 16, 2008
Step 10, Finishing the MySQL installation fails. The following message is returned: 1045 Access denied for user root@localhost.
By Patrick on Apr 18, 2008
“”"”
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…
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.
“”"
ive done that but the page didnt change, still the index.html page is loaded with the “it works” text not the info.php
what should i do?
By Sama on Apr 20, 2008
By Syahid A. on Apr 21, 2008
worked, pretty thanks
By Sama on Apr 21, 2008
Hello,
Perfect guide to install all three important server side applications. I had no problem installing all three.
Thanks a lot
Mallikarjuna Kenchappagoudra
By Malliikarjuna Kenchappagoudra on Apr 21, 2008
just a final question, after renaming index.html to index1.html and info.php to index.php
do we get the changes off by the end or what?
By Sama on Apr 21, 2008
By Syahid A. on Apr 22, 2008
Syahid,
Well everything went perfectly.
However I did have to back track a little. Let me explain… When enabling extensions I took the liberty to enable a few extra extensions that I needed and some I thought I wanted.
When I restarted I received a blank page. So I backed out the extensions that I didn’t need kept only what I needed and everything was back to perfect.
The moral here folks, follow the guide as directed and you’ll have no problems.
Make one change at a time, test, confirm then go on to the next change. If it fails then you know exactly what caused it and back it out.
Thanks again Syahid.
By Joe on Apr 24, 2008
By Syahid A. on Apr 25, 2008
Fantastic guide. I wish all those guys/programmers had half the brain you do. Well done!
By Margaret on Apr 27, 2008
By Syahid A. on Apr 27, 2008
wow thanks so much!
By chiqui on Apr 30, 2008
Hi
I have installed Apache 2.2, PHP 5 with MySQL 5 database following your tutorial and its work properly, thanks a lot, excellent tutorial.
But I have an problem with my free downloaded PHP web applications with mySQl backend from openburhan.com (2004), it doesn’t work, it cannot access the mySQl data. What do I have wrong and what should I do? Please help. Thank You in advance.
By bamby on May 3, 2008
By Syahid A. on May 3, 2008
Dude! This post was incredible! It saved my life… really! I am now able to install ‘Joomla!?’ without having to use those, really use but insecure, applications like XAMPP and other WAMPs (Windows + Apache + MySQL + PHP).
Thanks a lot!
CHeers.
By Victor Westmann on May 4, 2008
this is totally awesome.
By obinna henry on May 6, 2008
great guide! thanks.
got everything installed and running.
just one question:
where can i find this information?
MySQL username, password, and database name?
By lee on May 8, 2008
By Syahid A. on May 8, 2008
Thanks a lot!
This really helped
By South African dude on May 15, 2008
I had checked many tutorials. but yours guide is really working wonders…!!!
Thankz,
By ITsingh on May 16, 2008
By Syahid A. on May 16, 2008
it is gud to install.even small boy will do install by following ur recommended steps.bye
By praven on May 28, 2008
This was a very helpful tutorial. Thank you so much for writing it!
By Rachel on May 29, 2008
Thanks alot for taking the time. It is very straight forward and helps cut through the confusion I’ve read on other websites.
By John on Jun 4, 2008
By Syahid A. on Jun 4, 2008
Thank you for making this sane for me
By SH on Jun 4, 2008
Thank you man !!
By Alessandro on Jun 6, 2008
Thank you so much for taking the time to explain the processes properly! After deciding to join my husbands web design business I need to learn php, mysql and apache…… got stuck very quick and that was just installing them all! so fingers crossed!
There is just one thing at the end of changing the mysql settings in php5 my index.php does not look like yours?
any ideas?
By kim on Jun 18, 2008
By Syahid A. on Jun 19, 2008
When loaded into the browser (firefox) it showed the php information page and yours shows the Mysql info page. You also just put in www.syahid.com with no/index.php When i just put in my www address with no /index.php it just comes up with the IT WORKS page.Everything else works just fine
which is a surprise for me! hehe
By kim on Jun 19, 2008
By Syahid A. on Jun 19, 2008
LOL thank you! my appologies for being such a dohnut!
good luck? I think i will need it! Cheers 
By kim on Jun 19, 2008
I followed the instructions on my personal machine and did great. However, when I loaded everything on my server, everything worked until I tried to go into a mysql (3.23.49)database.
I’d sure love to get this problem fixed.
By papabill on Jun 29, 2008
By Syahid A. on Jun 29, 2008
Just discovered that mysql v3.23.49 was still on my personal machine. I installed v5.0.45 and now it does not work. Personal machine and server (separate machines) both have latest mysql, and mysql doesn’t work on either one.
By papabill on Jun 29, 2008
By Syahid A. on Jun 30, 2008
After uninstalling and re-installing everything about 5 times, I finally copied the ENTIRE mysql directory from my personal machine (the one that worked) to the server (the one I couldn’t get to work) and now they BOTH work well.
By papabill on Jul 1, 2008
By Syahid A. on Jul 1, 2008
Hey I need serious help.. I´ve been trying to connect mysql to php but I can’t. I’ve done like you said it still doesnt work.. on the info.php I can see that apache (2.2.8) and php (2.5.6) works… and I have a password and my hostname is root and Mysql works I don’t know that much how to use it though but seems fun..
How do I connect mysql with php??
/T
By TJ on Jul 2, 2008
It’s like this in my path and phrc
PATH C:\php;C:\Programmer\MySQL\MySQL Server 5.0\bin
PHRC C:\php\
By TJ on Jul 2, 2008
By Syahid A. on Jul 3, 2008
Hi Syahid I know you didn’t but I thought if you maybe thought something was worng there..
I still can’t get mysql on the info.php..
By TJ on Jul 3, 2008
By Syahid A. on Jul 3, 2008
Thanks!. It is a great help. I have tried many other sites for help. It did not work well. This is awsome.
By Thomas on Jul 8, 2008
thanks. it worked for me. it shows the mysql section in the phpinfo(). But i am unable to connect to the database. maybe there is err in the programming
By Thomas on Jul 9, 2008
Thanks so much for providing a simple, easy to follow guide to installing PHP 5. I was up and running quickly.
By Claire on Jul 10, 2008
Dear Syahid,
Your help has been fantastic on the installation of the above items. I am probebly not alone in this question, but have you done any other tutorials?
Thanks
By kim on Jul 15, 2008