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

Installing PEAR on PHP5

Thanks for answering my pervious post. I reinstalled PHP4 and used your IIS-AID, however that did not work.

Uninstalled it again. and Installed PHP5 per your instructions. Worked like charm. However, the software i want to install is called VTCalendar, http://vtcalendar.sourceforge.net/index.php, I followed the instructions but can not get it to work. It requires PEAR to be installed as well.

I'm assuming PEAR is out of the box ready in PHP5, do you have any resources in installing PEAR on my WIndows 2003 Server?

Thanks
Ricky

BeachBoy's picture

What's the best extensions to enable for PHP on IIS?

Dominic,

I'm curious about one thing regarding extensions for PHP 5.2.3 on Windows XP using IIS 5.1... Which extensions do you recommend that someone enable in their PHP.ini file for the best functionality for most PHP based applications? I plan to use Drupal 5.2 as mentioned in my previous post, as well as some other tools (CiviCRM, a OpenID server, etc...). If you could recommend some extensions (or write a article on the subject), it would be very helpful to me and others interested in using PHP 5. Also, please explain what the Pear libraries are used for, and where do we (I) download them, install them in PHP and so on.

Thanks in advance
~ BeachBoy

Brashquido's picture

@ Ricky Installing PEAR

@ Ricky

Installing PEAR should be as simple as opening up a command prompt, navigating to the root directory of your PHP install, and executing the go-pear.bat batch file. From there just answer the questions and you should be set.

@ BeachBoy

Enabling PHP extensions for IIS when using PHP as an ISAPI module is where things get a bit tricky, and you certainly do not want to go enabling PHP extensions unless there is a specific need. This is because a lot of PHP extensions are designed with the *nix multi process model in mind, where Windows/IIS uses a multi threaded model. This can cause major stability issues when using PHP extension that are not thread safe on Windows. Currently the only real viable way around this with PHP5 is to configure IIS to use PHP in CGI mode which is not effected by this, but this comes at the expense of a major performance hit (even using the new non thread safe binaries that significantly increase PHP CGI performance). If a PHP application requires a specific PHP extensions, then it will usually specify what one(s) it needs in its requirements documentation.

As for PEAR, have a read through the Wikipedia entry for more details. The PEAR package manager is included with the Windows distribution packages for PHP, and can be installed as per instructions above for Ricky. Again, if a web app requires a particular PEAR package, then that should be specified in the requirements documentation.
----------------
Dominic Ryan
3 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster

BeachBoy's picture

Woohoo! It works like a charm (so far)

Dominic,

Thanks for a very easy to follow install guide... I've now got my IIS Server setup for PHP, and I'm quite happy with the results. I don't know if anyone has mentioned this, but if you wish to use a PHP app that has an index.php file, you should set the Default Document section of the IIS manager to reflect this. Make sure you add it, then move it up the list before the iisstart.asp entry.

Regarding Pear, I'll be adding that as I need it. Now I'm off to test Drupal...

~Beach Boy

Anonymous's picture

Thaks for a great guide!!!

But i followed it to a tee. However when i pull up the http://localhost/phpinfo.php page it doesn't error out it just says done in the left corner of IE. It does nothing. Any Ideas? Thanks again for the detailed guide and any help you can offer.

Jason

Brashquido's picture

Ok, what version of windows

Ok, what version of windows are you using? Can you scan your IIS logs for phpinfo.php and post back the entire line if you find it?
----------------
Dominic Ryan
3 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster

Anonymous's picture

Great GUIDE!! Just facing one problem...

Hi Brashquido,

Thanks for the wonderful step-by-step guide. I'm still having a problem with the prompt that wants to download the file rather that run it. I've checked the MAPPING settings and they are correct. I also tried using:
http://localhost:8020/phpinfo.php BUT it wants to save the file. Other html files work fine though.

Any ideas?

Thanks

Anonymous's picture

PHP Code shows up in browser!!

Thanks for the great guide, but when I try the PHP test the code shows up instead of the page. It's like nothing gets processed.

I tried the small code you suggest and the same thing happens.

Thanks in advance

Anonymous's picture

Great Guide!!

Thank you very much!! This has been my 5th attempt at configuring IIS and PHP. After all the rubbish advice from the first search results in google, i hit the next button about 15 time and found your site! Thank goodness!!

Again, many thanks for the advice!

Damien

Brashquido's picture

If you are being prompted to

If you are being prompted to download php files rather than them being processed, then I'll stongly suspect that it is your application mapping. I know you said you've check it, but it is the only way I've ever been able to reproduce this problem. Double and triple check this, and if the problem continues feel free to send me a private message or use the website contact form to get in contact me as if the application mapping is not the issue I am as keen to find a resolution as you are.

As for php code being displayed in the browser window rather than being processed, then double check that your php code is enclosed in the proper php tags. Your php scripts may also be configure to use short tags, and if so you'll need to enable the short tag option in php.ini or modifiy your scripts to use the full php tags.

Thanks for the kudos Damien, glad to know the guide helped :)
----------------
Dominic Ryan
3 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster