February 25th, 2008
Following my previous series of posts on how to install IIS7, PHP and MySQL on Windows Server 2008, Bill Staples from IIS.Net left a comment on my blog suggesting that I checkout FastCGI.
According to IIS.net…
…the FastCGI component enables popular application frameworks like PHP be hosted on the IIS web server in a high-performance and reliable way.
Mike Volodarsky, a program manager on Microsoft’s IIS team, has expressed the following on his blog about why using PHP with FastCGI is the prefered method over ISAPI:
The main reason why ISAPI is not an adequate solution is the lack of thread safety in many popular PHP extensions. The PHP core itself is thread safe, and so are some of the extensions, so its possible that some applications will work correctly in the ISAPI environment. However, many production environments do experience instability with the ISAPI.
So that being said, let’s take a look at how to install configure the FastCGI extension to work with PHP 5.
As opposed to previous versions of Windows Server, the FastCGi module is already bundled with Windows Server 2008 so you don’t have to install it.
First of all, let’s make sure that the CGI role service is installed. Click on Start => Programs => Administrative Tools => Server Manager. Expand Roles, right-click on Web Server (IIS) and select Add Role Services. Make sure that CGI is checked and if not proceed with its installation.

Next head over to PHP.net’ download page and download the PHP Non-thread-safe Win32 binaries. At the time of this writing, the latest version of PHP is 5.2.5. Extract the content from the PHP archive into c:\php.
Launch the Internet Information Server Manager by clicking on Start => Programs => Administrative Tools => Internet Information Server Manager. Select your server from the left panel and then double-click on the Handler Mappings icon.

Click on Add Module Mapping from the right column:

Fill-in the PHP module mapping information as illustrated below and click on OK when done:

At this point PHP should now be working even though there no php.ini configuration file yet. To find out if PHP files are parsed correctly, create a new file at the root of website’s folder and name it phpinfo.php. Insert the following content into the file and save it:
<?php phpinfo(); ?>
Now try pointing your web browser to http://yourserver.com/phpinfo.php. If everything works properly you should see this page:

By default, IIS will look for PHP’s configuration file (php.ini) in c:\windows. To change this, launch the registry editor (Start => Run => regedit) and add a new key named PHP in HKEY_LOCAL_MACHINE\SOFTWARE\. Under the newly created key, create a new value named IniFilePath and set its value data to c:\php.

Close the registry editor when you’re done. Using the Windows Explorer, rename c:\php\php.ini-recommended to c:\php\php.ini and open it with your favorite text editor (no word processor). Find the extension_dir parameter and set its value to “c:\php\ext”. You might also want to uncomment extension=php_mysqli.dll and / or extension=php_mssql.dll if you plan to use MySQL or MS-SQL.
Once you’re done editing PHP’s configuration file, save it and close your file editor. You will need to restart IIS in order to apply the changes. This can be done through the IIS Manager:

I’ll try to perform some benchmark test to see how this setup compares to using php5isapi.dll.
Posted in IIS · Tutorials · Windows Server | 34 Comments
34 responses so far ↓
1. Response by : Ahmed on Feb 27, 2008 at 1:58 pm
Hi Stephane.. I tried to do as you say here but I think I have a problem..
it seems that I don’t have FastCGI in my laptop
I’m running vista ultimate 32-bit operation system 2006
I have installed IIS7 and I don’t know how to get the FastCGI for IIS7
when I choose add module mapping the window that pops has only three blanks input not four as in the pic here.. the Executable input is missing..
and in the module menu options there is no ((FastCGIModule))
I still can’t have the information about php with the code:
in the php file
they showed up only if I put this code:
PHP Information
does that mean I can not use it?
or I can just work fine with it?
thanks for help..
2. Response by : Ahmed on Feb 27, 2008 at 2:02 pm
the code doesn’t show up here, so I’ll delete some of it to make it show up:
html>
PHP Information
/body>
</html
3. Response by : Ahmed on Feb 27, 2008 at 2:04 pm
the first one is not complete
here it is:
html>
head>
title>PHP Information
body>
?php phpInfo(); ?>
</html
4. Response by : The Web Hosting Hero on Feb 27, 2008 at 2:16 pm
Hi Ahmed,
First of all, FastCGI is installed by default on Windows 2008 but not any other version (Vista, 2000, 2003). I’ve got it installed on my home pc, I’ll look into this and I’ll post here soon.
And second, for the phpinfo.php file, you don’t need to put anything else than this code:
< ?php phpinfo(); ?>
5. Response by : Ahmed on Feb 27, 2008 at 2:57 pm
so do you think I have a problem with the installation?
don’t you think it’s gonna work?
I really need it to work cause I’m gonna begin my lessons from the day after tomorrow..
can’t I download the fastCGI from anywhere on the net?
thanks Stephane
6. Response by : The Web Hosting Hero on Feb 27, 2008 at 8:56 pm
If the phpinfo() function doesn’t return anything, then no it’s not working.
Unless you are using Windows Server 2008, you have to install FastCGI manually.
You can get FastCGI for IIS6 here:
http://www.iis.net/downloads/default.aspx?tabid=34&g=6&i=1521
And FastCGI for IIS7 here:
http://www.iis.net/downloads/default.aspx?tabid=34&i=1299&g=6
I can’t tell you how to install it at this point but I’ll sure post about it someday.
Good luck!
7. Response by : Ahmed on Feb 28, 2008 at 8:02 am
thanks Stephane but the like of FastCGI for SII 7 says the page not found.. I think they already removed it..
and FastCGI for IIS6 can’t work on my machine..
I think I have to use apache instead of SII..
till I can get the new vista..
thank you a lot..
if you have any suggestions please let me know.. I’ll be here in whenever to see your work..
go ahead..
thanks again..

8. Response by : Tasneem on May 12, 2008 at 1:30 pm
HI
On my development server, at home, I cannot get cgi scripts to work. Can you tell me how?
Thanks
9. Response by : The Web Hosting Hero on May 14, 2008 at 7:23 am
Hi Tasneen,
I’ve posted the answer here: http://www.thewebhostinghero.com/articles/help-me-with-php-cgi-mysql.html
Hope this helps!
10. Response by : Nelson on Aug 1, 2008 at 2:51 am
Is working thanks for teh info
11. Response by : websologist on Sep 23, 2008 at 4:33 pm
I cant even get the IIS 7 page to display. Spent all day on this. You did in 6 minutes.
12. Response by : The Web Hosting Hero on Sep 23, 2008 at 4:35 pm
Hey Websologist,
Did you manage to finally make it work?
13. Response by : Nelson Leung on Jan 22, 2009 at 3:10 am
Great !!!
I follow your instructions and I have solved my problems.
14. Response by : Dana on Jan 23, 2009 at 10:34 pm
Hi Stephane;
Thanks for this tutorial. I think I’ve got PHP running on my server now. Following your suggestions to the letter did not work. I had to change the handler mappings on the default website to get the phpinfo.php file to run.
Thanks again.
d
15. Response by : Dana on Jan 23, 2009 at 10:38 pm
oops, might have figured out why your suggestion didn’t work. Seems I’m only running IIS6
16. Response by : Daniel on Feb 2, 2009 at 8:33 pm
Windows 2008 Standard
I had to add a Handler to the Default Web Site to get this to work. My guess is that the global setting only works on sites that haven’t been created yet.
Thanks for the tutorial
17. Response by : Lonestarjack on Feb 7, 2009 at 9:04 am
Vista, sp1:
I have followed your directions. Even reinstalled php 5.2.6. No matter what I do I keep geting failures that sayu “bad isapi module in list” or “can’t find isapi module:.
My question is — where is it called out to use isapi instead of fastcgi?
18. Response by : The Web Hosting Hero on Feb 9, 2009 at 3:27 pm
Unfortunately I don’t have my Windows 2008 Server anymore but on Windows 2003, you will find the ISAPI filters under Web Sites > Properties > ISAPI Filters
19. Response by : lonestarjack on Feb 11, 2009 at 8:28 pm
Wow!After 2 months I finally can run PHP on my laptop. I didn’t understand that there are multiple places to change the module mapping info.
I was on the verge of reinstalling Vista because I thout the registry was messed up.
20. Response by : Corey Gouker’s Machine Inside the Mind » Blog Archive » On migrating to WordPress from dasBlog… on Feb 12, 2009 at 1:26 pm
[...] Remember to set the PHP registry settings if you extract PHP from the ZIP http://www.thewebhostinghero.com/tutorials/windows2008-iis7-fastcgi-php.html [...]
21. Response by : Carlos on Jun 2, 2009 at 3:18 pm
Whats wrong with just plain CGI?
My admin installed php-cgi.exe (v 5.2.9.9)
on Win 2008 IIS7
Should I reinstall to get the FastCGI?
22. Response by : The Web Hosting Hero on Jun 3, 2009 at 8:52 am
Hi Carlos,
There’s nothing really wrong with using PHP as a CGI although you’ll gain more performance with FastCGI.
Stephane
23. Response by : marks on Sep 17, 2009 at 8:48 am
Well it works! but… at the beginning u must first made Web Servver ISS (if u dont have so…) and after this make CGI.
I am using also web expression 2 Good Luck! It took me only 10 minutes coz I am beginner in this environment.
24. Response by : ex3m on Feb 13, 2010 at 5:05 am
its work fine thnx
in phpinfo.php no need enything else
?php phpInfo(); ?>
no need all of this configuration
you can find installer of PHP5:
“php-5.3.1-nts-Win32-VC9-x86″
or whatever is your machine preformance
an all you need to config is
regedit and crating phpinfo.php
*sorry for my language*
25. Response by : Wentao Su on Apr 19, 2010 at 8:40 pm
To those who get the error message “The FastCGI process exited unexpectedly” and trying to use php 5.3.2, pls try the following:
add a line in php.ini like date.timezone = “GMT”, and it should work.
For more timezone format at:
http://php.net/manual/en/timezones.php
26. Response by : Terry on Jun 5, 2010 at 12:52 pm
I keep receiving the HTTP 500 Internal Server Error when I try running a PHP file on my Windows Server 2008 machine. The php file I am attempting to use is supposed to open a text file located within the same directory as my website and the php file. When I run the phpinfo.php file, it loads fine without any problems. Here is the php contents that do not seem to work for me:
27. Response by : Orazio on Jul 27, 2010 at 3:29 am
I’m receiving the HTTP 500 Internal Server Error too, error is located in php5ts.dll module.
If I disable extensions in PHP.INI, phpinfo.php works correctly.
I checked the extensions path and it is correctly set (c:\php\ext).
If i doubleclick on php-cgi.exe, I receive the same error (if extensions are enabled in php.ini).
What can I do? Thanks
28. Response by : Tasneem on Nov 15, 2010 at 2:32 pm
HI
I reinstalled new php ver. 5.3.3, and as stated elsewhere, there is no php5isapi.dll file in the zip files. So, I did the fastcgi install, but now there is only a blank page on the phpinfo.php page on my server.
When I check the source code, the code is there, so there is some error in the installation. how do i get the php to work on iis7, windows server 2008, without php5isapi.dll and fastcgi not working?
thanks
29. Response by : Manny Ramirez on Dec 3, 2010 at 5:07 pm
There is a easier way of doing it now, just following the link below.
http://www.microsoft.com/web/gallery/install.aspx?appsxml=&appid=PHP%3bPHP%3bPHP
30. Response by : Jose on Dec 20, 2010 at 10:43 pm
Worked for me fitst time.
Also copied my old php.ini frommy version 5.16
Thanks for the tip
31. Response by : Tuan on Jan 14, 2011 at 12:00 am
I installed new PHP version 5.2.16 installer file onto my webserver which is using IIS 7 of Windows server standard 2008 64bit, sql server standard 2008 64bit. After following step by step above instruction, i try to open phpinfo.php. It’s fine. But when I try to connect SQL database.I received an error message: “HTTP Error 500.0 – Internal Server Error, The page cannot be displayed because an internal server error has occurred.Detailed error information: Module FastCgiModule, Notification ExecuteRequestHandler, Handler PHP_via_FastCGI,Error Code 0×00000000, Requested URL http://localhost:80/optictest/index.php
Physical Path E:\Websites\OPTIC\LIVE\www\index.php
Logon Method Anonymous
Logon User Anonymous
Who can support me, please?
32. Response by : Noel on Apr 4, 2011 at 1:45 am
I would like remind people that they should disable hide known extension as this was giving me No input file specified error
go to start =>control panel (view in icons instead of category view)
=> folder options => view tab => uncheck hide extension for known file types
http://www.iis-aid.com/articles/trouble_shooting/no_input_file_specified
33. Response by : Martin on May 28, 2011 at 4:44 pm
Thanks worked like a charme !!
I was upgrading from w2k3 to w2k8 and it works different in some ways.
This article helped me a lot, thanks
34. Response by : Michael on Jun 16, 2011 at 10:30 am
Running IIS 7 on W2k8r2 it runs fine, but command line complains about not finding php_mbstring.dll but it is there. I copied it to all the usual places windows looks for the dll and it just never sees it.
mdvc9 Mar 17 build PHP 5.3.6 official non-threadsafe.
The PHP extension is 20090626.
it also complains about not finding PHP_exif and it is looking in the wrong directory. should be c:\php\ext according to the config file and reported in phpinfo. But the error message looks in the initial install directory.
The config is set to:
PHPinfo reports
mbstring
Multibyte Support enabled
Multibyte string engine libmbfl
HTTP input encoding translation disabled
Multibyte (japanese) regex support enabled
Multibyte regex (oniguruma) version 4.7.1
Directive Local Value Master Value
mbstring.detect_order no value no value
mbstring.encoding_translation Off Off
mbstring.func_overload 0 0
mbstring.http_input pass pass
mbstring.http_output pass pass
mbstring.http_output_conv_mimetypes ^(text/|application/xhtml\+xml) ^(text/|application/xhtml\+xml)
mbstring.internal_encoding no value no value
mbstring.language neutral neutral
mbstring.strict_detection Off Off
mbstring.substitute_character no value no value
Leave a Comment