Installing PHP 5 on IIS in 5 simple steps

Categories:

Restart and verify

Almost done now. Restart your server so that all the changes we have made are made effective in one swoop. Once your server has restarted create a file called phpinfo.php and place it in one of your websites that you can get access to. Open the file and enter this code;

<?php

phpinfo();

?>

Save the file and then open your web browser and access you phpinfo.php file and you should be presented with a screen detailing your PHP configuration. If this is what happens then you are up and running, if not then something has gone amiss. Feel free to ask me for help in the forums though.

As already stated if you require PHP 4 (for legacy code, etc) then your job is much easier. Just Download the IIS Aid PHP Installer and run through the GUI based installation wizard and everything is setup for you. With PHP now enabled you are on your way to being able to utilize one of the most popular web scripting languages in the world, which is used by thousands of free, and commercial web applications. Be sure to check back on this site in future for some PHP tuning tips and performance comparisons to make sure you are getting the most out of your PHP environment.

Comments

Anonymous's picture

Thanks

Just wanted to say thanks for taking the time to write this tutorial. I installed php and mysql with apache before, but it's been a while, and I'd never worked with IIS before until recently. This was a great tutorial to get me up and running quickly, everything worked like a charm.

Anonymous's picture

http 500 error

I followed steps above to install PHP 5.2.3 for IIS 5.1. But when I test it, I got HTTP 500 error. Any solution?

Brashquido's picture

A 500 error could be caused

A 500 error could be caused by a few things. Most immediate one that comes to mind as I had to deal with it just the other day is the fastcgi.impersonate setting in your php.ini file is set to 1.

----------------
Dominic Ryan
3 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster

Anonymous's picture

Uninstall PHP 5

Great article. I had PHP 4 installed, but the PEAR option was not installed. So I thought to Uninstall and install a version that had PEAR. Everything was working fine PHP4. I uninstalled, reboot, and then reinstall PHP5 using the MSI installer. However, my PHP webpages came back with an 404 error.

Whats the best way to uninstall and remove all PHP related files from my Win2003 server? and to a complete reinstall following your instruction.

Thanks.
Ricky

Brashquido's picture

Might be worth double

Might be worth double checking that you enabled a web service extension for PHP5 before we look at removing all things PHP from your system. Without knowing how PHP has been installed on your system there is very little chance of me being able to tell you exactly where and what to look for, but I can give you a general guide;

1) Ensure paths referencing PHP are removed from the PATH variable
2) Delete all PHP files
3) Check your windows system directories for PHP files which are sometimes copied over from the PHP directory when the PHP paths are not set correctly during setup.
4) Delete all PHP web service extensions from IIS
5) Delete all PHP application mappings from IIS

That should about cover all the obvious ones I can think of for now...

----------------
Dominic Ryan
3 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster

Anonymous's picture

a perfect worl a perfect guide

I NEVER write comments on these sites. For your guide I had to. VERY good job. 7th instruction set. Worked like a CHARM

Anonymous's picture

Very strange PHP session problem on IIS5, IIS6

Hi Ryan,
i installed PHP on my IIS5 (XP Pro), IIS6 ( win2k3 server SP2 R2) , everything works fine, except PHP session.
my server IP is 192.168.1.60
test.php
< ?
session_start();
?>
if i open this test.php like this: http://localhost/myweb/test.php, no error occur, but if i open the test.php like this: http://192.168.1.60/myvdir/test.php, it says:

Warning: session_start() [function.session-start]: open(C:\WINDOWS\TEMP\\sess_ii5515gqj838mhpugm5lr267e2, O_RDWR) failed: Permission denied (13) in C:\MyWeb\test.php on line 2

Warning: Unknown: open(C:\WINDOWS\TEMP\\sess_ii5515gqj838mhpugm5lr267e2, O_RDWR) failed: Permission denied (13) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct () in Unknown on line 0

any idear?
Thanks.

Jaive

Brashquido's picture

Hi Jaive, Can you open your

Hi Jaive,

Can you open your php.ini file and find the line with the session.save_path directive in it? Once you've found it post back here with the entire line.
----------------
Dominic Ryan
3 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster

BeachBoy's picture

Newbie questions

Hello Dominic,

I have a few questions as a newbie using IIS and PHP 5.2.x for you. I'm just getting started using IIS as a subdomain of my site (http://xtra.thecafeunderground.net), mostly because my hosting provider is running the main site on Linux w/ Apache, PHP 4.3.1, and MySQL 4/5. I wanted a testbed for Drupal 5.2, and I've already got a SSL certificate installed (from CACert). My questions for you are as follows:

1. If I install PHP 5 per your instructions in the how-to, can I use a preconfigured PHP.ini file (for example, the one created using the IIS-AID installer after I remove the PHP 4 install)?

2. Do you recommend using any other tools for the testbed server besides PHP and MySQL? If so, are any of them open-source or free?

3. Do you have any other tips for a newbie wishing to use Drupal on IIS?

Please feel free to contact me when you can. Thanks in advance.

~ BeachBoy

Brashquido's picture

Hi BeachBoy, 1) Mostly, but

Hi BeachBoy,

1) Mostly, but there are a few differences between PHP 4 and 5. For instance the MySQL client is loaded automatically in PHP4, but loaded separately as a PHP extension in PHP5. There also might be issues with paths and things. It could be done, but I'd think there would be fewer issues with just altering the existing PHP5 ini file.

2) Depends totally on what you want to do. PHP is by far the most popular open source scripting language around at the moment, and as such most open source web apps utilize this language. About the only other "must have" I'd say you need there is Perl (check out Activestate), and maybe if you're feeling like it RoR. Obviously you could also look into .NET for running web apps such as Dot Net Nuke.

3) Make sure you backup and just spend time with it. Only other Drupal specific thing I'd recommend you look at is Clean URL's (such as use on this site). There are presently only a few offerings for IIS that enable you to manipulate URLS to create this effect. I'd recommend having a look at Helicon ISAPI Rewrite Lite which is free, and then check out my guide in the "how to guides" section.

Let me know if I can be of any more help.

----------------
Dominic Ryan
3 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster