Articles
Installing PHP 5 on IIS in 5 simple steps
Configure PHP.ini
You could very easily write a series of articles regarding setting the various php.ini directives, so to try and keep this article short I will just deal with the basics here. When serving PHP on IIS the php.ini file is the only place that options are set, and if no php.ini file can be found then the defaults are loaded. The limitation of a single php configuration for an entire server is perhaps one of the biggest disadvantages with hosting PHP applications on IIS, especially in shared hosting environments.
There are actually only a handful of setting you will might want to look at configuring in php.ini, and they are the path to your extensions, sessions, and upload directories. You'll also may wish to enabled a few PHP extensions to get added functionality from PHP that might be required by some PHP apps, and perhaps set some PHP logging options.
- Open your PHP installation directory (e.g D:\PHP) and copy php.ini-recommended and rename the copy to php.ini
- Open php.ini and do a search for extension_dir = "./" and replace it with extension_dir = "D:\PHP\ext" where D:\PHP\ext is the path to your extensions directory (it's the one with all the files that begin with "php_" in it). The path to your PHP installation will be used for the next several steps, so take care that you modify them to suit your own environment.
- Search for ;session.save_path = "/tmp" and replace it with session.save_path = "D:\PHP\sessions" (note the semi colon (;) is removed). This will be used to store PHP session information which is used by many PHP applications.
- Search for ;upload_tmp_dir = and replace it with upload_tmp_dir = "D:\PHP\upload" (note the semi colon (;) is removed). This is used for all your HTTP upload files, and if not set your system temp will be used.
- Search for ;error_log = filename and replace with error_log = "D:\PHP\log\php.log" (note the semi colon (;) is removed). This is where all your PHP logging information is kept when enabled. You can also configure PHP to log data to your Event Log, but it requires loosening the privileges on the IUSR_COMPUTERNAME account IIS uses.
- Search for ;extension=php_mysql.dll and remove the semi colan (;) from infront of it so it appears as extension=php_mysql.dll. You'll almost certainly need this PHP extension loaded as any PHP application that uses the MySQL database will need it.
- Add new comment
- 743371 reads

Comments
You have definitely
You have definitely uncommented php_mysql.dll in your php.ini file? If so, then have a look at the path for the "Loaded Configuration File" value near the top of your phpinfo page. Is this correct?
----------------
Dominic Ryan
5 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster
Excellent Guide
Thanks a lot for such a excellent and elaborative guide. Really helpful.
Regards
Problem installing on IIS 7
Hi, and first thank you for this nice guide.
However I have problems installing on IIS 7 as the interface is really different from previous versions and I am far from beeing a specialist in configuring IIS.
I did evrything you said (at least I think so) but I have a 404.17 - Not found error when calling the phpinfo.php page.
Detail error should be something like "aked content seems to be a script and won't be handled by the static file manager".
Sorry if that message seems weird but it is a translation as my system is in French.
Just for information the web site works correctly if I call an .htm or .aspx(.net) file.
If you have any hint...
installed aid to server 2008 with iis 7
and got problems.
well, before I could run php for all sites. PHP had been installed manually form php distributive. but I couldn't run smarty.
Today I thought to implement Aid tool. First removed php and installed tool. The first strange thing I sat that it said me that Fast-CGI is not installed. It was! And offered use ISAPI. ok. Asked to direct all php sites. Directed.
In result now I can't run any site having error:
HTTP Error 404.2 - Not Found
The page you are requesting cannot be served because of the ISAPI and CGI Restriction list settings on the Web server.
•No handler mapping for this request was found. A feature may have to be installed.
•The Web service extension for the requested resource is not enabled on the server.
•The mapping for the extension points to the incorrect location.
•The extension was misspelled in the browser or the Web server.
Checked according these directions. Everything looks ok but still nothing works. What to do now?
Help please!
Almost working
Hi,
First of all, it's nice to see some dedicated person sharing his knowledge with the community. Great work.
Now with my problem.
I am using Windows XP Pro SP3
IIS 5.1 and PHP 5.2.6.6.
I got the PHPInfo.php working fine.
But when I call a .php page from a button, only the code of the .php appears. I have been working for the last 2 days on this problem, but can't seem to find the solution. I checked, double checked and triple checked everything, uninstall IIS and PHP. I did the reinstall to get the same result.
I also must say that I tried to install php 5.2.6.6 with the Apache 2.2 before but had similar problem. The only difference is that it prompted me to download or save the file instead.
Any thought about this ?
Thank you for reading this.
Pierre
Almost working part 2
Hello again,
Well I think I have the solution to my problem. Would like your advice if it is normal.
When I access my file like this (http://localhost/Exercice1PHP.html) and click on the cmd button everything works fine but when the page is accessed like this (C:\Inetpub\wwwroot\Exercice1PHP.html)this is when I get this:
Le garage de Bob
Résultats de la commande
echo '
Commande traitée.';
?>
as a result.
So, is it right to say that when working on the local server, the address always has to start with HTTP://localhost/ or HTTP://127.0.0.1/ ?
Hope to hear from you soon
Best regards,
Pierre
Hi Pierre, This is actually
Hi Pierre,
This is actually quite a common issue. PHP is an interpreted script, meaning it must be proceesed by either PHP CLI or a webserver configured to process PHP content into a format that can be rendered by your browser. When you access your PHP scripts locally using http://localhost or http://127.0.0.1 you are invoking your locally installed webserver to proccess the requested content. When you try and access these scripts directly (i.e C:\Inetpub\wwwroot\Exercice1PHP.html) then you bypass your webserver and the PHP script is not executed.
----------------
Dominic Ryan
5 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster
Directories
So if I want to work on more than one project, how do I manage my files. I tried to create directories, but the page pages won't show at all. I have the HTTP 404 error(can't findthe page). Exemple http://localhost/PHP/chapitre2/orderform.html
But when I but the page directly in the wwwroot folder like this http://localhost/orderform.html it is working fine.
Is there a way I can use so I don't put all my files in the same directory?
Thanks again for your assistance. greatly appreciated
Pierre
404 could mean permissions
WHen you've confirmed that the files are definately there and are sure the path is correct, then a 404 error usually translates to there being a dile permissions issue. Ensure all you web files have at least NTFS read permissions to your IIS user account (usually IUSR_COMPUTERNAME).
----------------
Dominic Ryan
5 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster
WHen you've confirmed that
WHen you've confirmed that the files are definately there and are sure the path is correct, then a 404 error usually translates to there being a dile permissions issue. Ensure all you web files have at least NTFS read permissions to your IIS user account (usually IUSR_COMPUTERNAME).
I have tried and couldn't get it working. Any other ideas ?
Would the fact that I have Visual Studio.Net 2008 installed be the cause as it also use IIS.