PHP and MySQL are a powerful combination when it comes to providing dynamic content to your user base. Over the years, these two products have grown well beyond their initial niche and now power some of the world's busiest sites. While both products are open source and initially ran on UNIX/Linux, for quite some time, both have been available for the Windows platform. In this article, I will provide you with step-by-step instructions for installing and configuring these products in a Windows environment. For some of you, the information presented here will be simplistic, but this article is designed to be a complete step-by-step guide toward accomplishing the goal in the article title.
This particular software combination is often referred to as WIMP (Windows/IIS/MySQL/PHP), taking after the popularisation of the LAMP (Linux/Apache/MySQL/PHP) name for the Linux world.
My lab system for this article is running the 64-bit version of Windows Server 2003 Enterprise Edition.
Step 1: Install the Application Server role onto your Windows Server 2003
R2 system
For this example, I'm going to use IIS as my Web server. You
can also opt to use PHP and MySQL with Apache in which case you don't need IIS,
but I am not going this route in this example.
To install the Application Server role onto your system, from the Start menu, choose Manage Your Server. On the Manage Your Server main window, click the "Add or remove a role" option. (Figure A)
Figure A |
![]() |
| Installing the Application Server role onto your server makes it possible to host Web sites. |
Windows will search your server for existing roles and then provide you with a complete list of roles available for installation. (Figure B)
Figure B |
![]() |
| The Application Server role includes both IIS and ASP.net. |
During the server role installation process, you may be asked to insert your Windows Server CD. The files needed for this role are on CD 1.
When you're done, the Manage Your Server screen is updated to reflect the addition of the new role.
Step 2: Download PHP and MySQL
At this point, your server is ready to start serving up Web
pages. But, since you haven't yet installed PHP or MySQL, the pages will be static.
Before you can install PHP and MySQL, you need to download the Windows versions
of the software from their respective Web sites.
MySQL
I'll start with the MySQL installation. As of this writing, MySQL 5.1 is in
beta, with version 5.0 available for general use. Even though I'm installing
MySQL onto a 64-bit edition of Windows, I'll download the 32-bit version of the
product. After all, PHP, which will be on the same server, is not yet generally
available for 64-bit hardware, which means that IIS needs to be kicked down to
32-bits on the server as well, so there's no way to stay fully 64-bit. MySQL is
available in three editions: Essentials, Complete, or an edition sans
installer.
- Essentials: The Essentials package is an MSI installation file intended to meet the needs of most users.
- Complete: The Complete package, as you might expect, includes more components than Essentials, including a suite of benchmarking tools.
- Noinstall: This package is the same as the Complete package, but does not include the Configuration Wizard or an installer and must be installed manually.
For the purposes of this article, the Essentials package is desirable. In this case, the file I'm downloading is named mysql-essential-5.0.24a-win32.msi and it's saved to my desktop.
PHP
To add dynamism to your site, using a language like PHP is a necessity, particularly if you want to pull information from a database such as MySQL. There are two different versions of PHP: a 4.x series version and a 5.x series version. If you're using scripts from an older site, you may need the 4.x series version of PHP since 5.x introduces a number of changes. Since I'm creating a brand new site, I'll stick with the latest edition of the product. As of this writing, that is version 5.1.6.
The name of the downloaded file is php-5.1.6-Win32.zip.


Do you need help with MySQL? 



1
sharif - 31/10/06
i want to learn mysql and php
» Report offensive content
2
Ross - 01/11/06
"After all, PHP, which will be on the same server, is not yet generally available for 64-bit hardware"
This is true, however, for anyone interested there is a version available (but not guaranteed stable):
PHP x64 for Windows is available at http://www.fusionxlan.com/PHPx64.php
Latest is 5.1.5, however, once 5.2 is released it will be ported soon after.
» Report offensive content
3
Iain Findlay - 14/11/06
Hi,
I am having trouble getting your sample php file to display the table contents. I am viewing the php site from my xp pc, not the browser on the server.
I recieve the following error:
Fatal error: Call to undefined function mysql_connect() in D:\Web\phpbb\dbtest.php on line 6
I would love to get this working before moving on!
» Report offensive content
4
Iain Findlay - 15/11/06
Hi,
I am having trouble getting your sample php file to display the table contents. I am viewing the php site from my xp pc, not the browser on the server.
I recieve the following error:
Fatal error: Call to undefined function mysql_connect() in D:\Web\phpbb\dbtest.php on line 6
I would love to get this working before moving on!
» Report offensive content
5
Rajnish - 18/11/06
After doing all the steps I am not able to view the test page it all comes blank.
What could be the reason Please help
» Report offensive content
6
Jigar - 28/03/07
Hi all,
To get all the hassle out of the way for installing and setting Apache - PhP - MySql, you can look at the project at http://vertrigo.sourceforge.net/
This project combines Apache-PhP-MySql and other things like SqlLite etc. in a single setup. A single setup executable sets up all softwares. It also comes up with a common page for looking at the status of various components and change setting.
Regards
Jigar
» Report offensive content
7
Dusan - 30/03/07
Hi to all,
I suggest better free and easy solution to keep all together (Apache, PHP, MyAQL) : XAMPP - http://www.drdrksa.info/xampp-all-in-one/
» Report offensive content
8
Leroy - 19/05/07
Thank you for this post. It was very helpful. There were two typos (at least I think they were) in the dbtest.php text.
The first is "php" was missing after "<?" (without the quotations, of course), so that it should have read "<?php>"; I could not get the page to display the records until I made that change.
And the second (not at all critical) is near the end of that same file (dbtest.php) it should read "<br>" instead of "<br;>" (with quotations) if you want each record to be displayed on its own line.
Again, thank you for this article.
» Report offensive content
9
fazal - 27/06/07
fdfdfdgdgd
hkhjkhjkjh
j,jlhjlhjlh
» Report offensive content
10
Kapil - 27/07/07
I too wanna learn PHP n MySQL? How could the developers for me developer help...THe easiest way!
I tried PHP on ABYSS
» Report offensive content
11
John Wood - 16/09/07
Hi i have been trying to get php5 running on my win2k3 r2 x64 server but after running the script cscript adsutil.vbs set w3svc/AppPools/Enable32bitAppOnWin64 1 i get a service unavable message when trying to load and web pages on the server if i run the same script with a 0 setting it back to 64bit everything works fine again. Any assistance with this would be much appriciated. Thanks John
» Report offensive content
12
Daud - 16/10/07
This is a great tutorial, but I have a problem. I cannot get php to work on IIS7. If anybody can help me with this issue please email me at day3dunlap@yahoo.com or submit a response here. I greatly appreciate any help I can get. Thanks.
» Report offensive content
13
Tony Leeson - 22/10/07
After really battling to get php & mysql set up on IIS your tutorial was a great help.
I did have to change the tags from <? to <?php and remove the space between the '?" and the '>' in the closing tag - and then IT WORKED!
Thank you.
» Report offensive content
14
Mahantesh - 31/10/07
I want know to how to install the php on windows OS using php windows installer4, MYSQL Server, Apache web server.
Tell the all the steps from starting so that i can install it and carry on my work on php..
» Report offensive content
15
que0x - 03/01/08
complete tutorial found here :
http://blahblah.webunusual.com/index.php/2008/01/01/x64-fashioned-speed-iis-on-x64-php-and-fastcgi/
it is working !
» Report offensive content
16
Marcus Linux - 17/01/08
I had PHP5+Apache5+MySQL+Tomcat+mdjk working on windows environmnet; however, we migrated to Linux server the database stop writing.. Anyone knows what is going on? Please advise.
» Report offensive content
17
Anwar - 30/05/08
Great article. everything working fine.
thanks a bunch.
» Report offensive content
18
anonymous - 26/06/08
OMG that you for this article; it saved me a lot of broken keyboards and monitors.
» Report offensive content
19
Pradeep - 28/10/08
I am facing following problem in php :
the work in a test base webserver ("Developer")
but database is kept some different machine on a intranet ("SERVER")
I couldn't access the database from the host - "SERVER"
HOW I CAN???????
Regards,
Pradeep
» Report offensive content
20
brendon - 20/11/08
Hi;
Thanks very much for this great article it enabled me to get php up and running on IIS in no time. However i did run into one issue, after following your instructions exactly the mysql module for php still wasnt loading, i am certain that i had configured my php.ini correctly and that there where no other rouge php.ini's on my pc, but alas it still wouldnt work. Eventually i solved it by adding the php ext path to the path variable in my system variable!
» Report offensive content