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.

  1. Essentials: The Essentials package is an MSI installation file intended to meet the needs of most users.
  2. Complete: The Complete package, as you might expect, includes more components than Essentials, including a suite of benchmarking tools.
  3. 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 PHP? Gain advice from Builder AU forums

Comments

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

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

<code>
404 : Sorry! The code is commentarily encrypted n cannot be decreypted to see here.
- Thank You
</code>

» Report offensive content

10

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

11

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

12

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

13

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

14

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

15

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

16

Anwar - 30/05/08

Great article. everything working fine.
thanks a bunch.

» Report offensive content

17

anonymous - 26/06/08

OMG that you for this article; it saved me a lot of broken keyboards and monitors.

» Report offensive content

18

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

<?php
$myServer = "SERVER";
$myUser = "admin";
$myPass = "laserlaser";
$myDB = "[PW-MDB08]";

//connection to the database
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");

//select a database to work with
$selected = mssql_select_db($myDB, $dbhandle)
or die("Couldn't open database $myDB");
....

» Report offensive content

19

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

20

Bre - 11/03/09

How to do these ?

Now, create a system variable named "PHPRC" and assign to it the path to the php.ini file. If you opt to do this instead of creating a registry entry to achieve the same goal, make sure your PHPRC variable contains only the path to php.ini, and not the path plus the php.ini file name.

» Report offensive content

21

Michael - 06/05/09

I am running windows server 2003 and I have everything working except creating a connection to mysql database. I am using Apache instead of IIS. Do you know of a updated tutorial for Apache 2.2, PHP 5.2.9 and MySQL 5.1?

Thanks in advance.

mz

» Report offensive content

22

Pranam - 06/05/09

Hi

I am using the article for my own adventure. Is it possible to use just a windows XP machine. I am not worried about making my application accessible to everyone.

Will I face any problems if I ignore the first few steps regarding IIS ?

I guess in that case I will need apache. Which version of apache can I use ?

Thanks
Pranam

» Report offensive content

23

shawn - 29/05/09

I've installed PHP a dozen times but always need a good guide to assist. I found yours to be great until step #3 of the PHP install...you lost me on that one. You tell what to do instead of show what to do. If we don't know what your technical terms mean, we are lost...

» Report offensive content

24

gilbertsavier - 14/07/09

Take thumbnail of URL home page

Hi Qualifiers,
I have a simple task in PHP that is we take a thumbnail an one of the website home page, when we give an URL like in one text box that time control goes to home page of the specified URL and take a picture that home page as a thumbnail and stored in an our specified local disk like we give more than one an up to 100 URLS at a time and stored orderly stored in an our specified local disk so you have any tool or PHP code for this task please post an our forum I will try that.

Thanks in advance for your help.

Regards,
Gilbertsavier.

» Report offensive content

25

aparna - 02/12/09

I have followed exactly what ever is mentioned above it includes downloading the php and mysql as mentioned and its configuration.

"http://localhost/test.php" work, it displays the PHP Info

But "http://localhost/dbtest.php" doesn't display any thing, it blank.

In mysql the corresponding table & values are available.
Could you please let me know what could be possible error.
Further i want to install moodle using the same PHP & mySQL.
Could you please let me which moodle veriosn (32 bit) i should download & what should be its configuration settings?

» Report offensive content

26

Tony Robins - 17/02/10

to get PHP to talk to MYSQL I had to do the following:

Locate the libmysql.dll file in C:\PHP and copy it to C:windows\system32.

You may need to copy php_mysql.dll and php_mysqli.dll from C:\PHP/EXT as well

Hope this is useful

» Report offensive content

27

Goldberg - 18/02/10

look I have tried and everything copy pasting dll, checking the php.ini , nothing works. Can u really help?

Fatal error: Call to undefined function mysql_connect() in c:\Inetpub\wwwroot\myweb\data.php

» Report offensive content

Leave a comment

You must read and type the 6 chars within 0..9 and A..F

* indicates mandatory fields.

27

Goldberg - 18/02/10

look I have tried and everything copy pasting dll, checking the php.ini , nothing works. Can u really help? Fatal error: ... more

26

Tony Robins - 17/02/10

to get PHP to talk to MYSQL I had to do the following: Locate the libmysql.dll file in C:\PHP and copy it ... more

25

aparna - 12/02/09

I have followed exactly what ever is mentioned above it includes downloading the php and mysql as mentioned and its configuration. ... more

Log in


Sign up | Forgot your password?

  • Staff Microsoft shows off IE9 preview

    This week, highlights from Microsoft's MIX10 conference and more in the Roundup. Read more »

    -- posted by Staff

  • Chris Duckett IE9's H.264 vote killed Ogg

    In a split decision by the judges, the winner of the W3C/WHATWG video codec consensus is H.264, taking home the future of video playback on the internet while loser Ogg goes home with nothing but thoughts of what might have been. Read more »

    -- posted by Chris Duckett

  • Staff Google launches Apps Marketplace

    Google launches and app store, while Mozilla plans to re-write its open-source license. More of this week's news in the Roundup. Read more »

    -- posted by Staff

What's on?

  • Optus Deal

    Broadband + home phone + PlayStation®3 in a single package price!