Installing PHP 5 on IIS 6
Written by: Mark Wilson
I’ve run PHP with Microsoft Internet Information Services (IIS) before (running on a Windows XP laptop) and I seem to remember the installation being quite straightforward. Even so, tonight I was installing PHP 5.2.6 with IIS 6 (on Windows Server 2003 R2 Enterprise x64 Edition) and I ran across a few issues. This post describes what was involved:
- Firstly, PHP can be installed in CGI, FastCGI or ISAPI mode. I used ISAPI.
- Secondly, there is anecdotal evidence that the Windows Installer version is problematic – for that reason you may prefer to use the ZIP file and perform a manual installation (as I did), following the instructions on the IIS Admin blog, which were:
- Extract the files to a location of your choice (I used C:\PHP to keep it simple but C:\Program Files (x86)\PHP would be better).
- Rename php.ini-recommended to php.ini.
- Edit the
extension_dirline in php.ini to readextension_dir = C:\<em>phpinstallationfolder</em>\ext. - Add the PHP installation folder to the
%path%system variable (e.g. append;C:\PHPto the existing path). - Create a web service extension for PHP using
cscript iisext.vbs /AddFile c:\<em>phpinstallationfolder</em>\php5isapi.dll 1 PHPISAPI 1 “PHP ISAPI”. The new extension should show in IIS Manager with a status of Allowed. - Create an application extension mapping for .php files. Following the advice on the IIS Admin blog article that I referenced previously will remove all other mappings so I used the IIS Manager MMC instead (Default Web Site Properties, Home Directory, Configuration to add a mapping to the executable at
c:\<em>phpinstallationfolder</em>\php5isapi.dllusing extension.phpfor all verbs). - Create a test file called phpinfo.php containing
<?php phpinfo(); ?>. - Use a web browser to navigate to http://servername/phpinfo.php and the PHP information page should be displayed.
- If you are running on 64-bit Windows there are some extra steps in order to avoid an HTTP 500 Internal server error or the message %1 is not a valid Win32 application. It seems that this is caused by trying to load a 32-bit application (in this case PHP) inside a 64-bit worker process (as described in Microsoft knowledge base article 895976). To resolve this issue, enter
cscript adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1.adsutil.vbsis one of the scripts installed into the wwwroot\AdminScripts folder but if you have removed it to secure the server (as I had), then it may be temporarily copied back to the server from another IIS installation. - To ensure that PHPinfo reflects the correct location of the php.ini file, create an environment variable called PHPRC referring to c:\phpinstallationfolder and restart the server or, alternatively, set the appropriate registry keys (although neither option seemed to have any effect for me).
Posted: 9:00 on Thursday 7 August 2008 under IIS, PHP.
Comments: 4
RSS (for comments on this post only)Share This
Comments
Comment from Tim Anderson
Time: Thursday 7 August 2008, 14:08
Why not FastCGI, which is meant to perform much better?
Tim
Comment from Anonymous
Time: Tuesday 23 September 2008, 15:54
all the config guides hav given the same solution and my .php files won’t run.I have IIS 6.0 and have installed php 5.2.6 (noticed the php.exe only opens in dos mode an the win version didn’t even start)How do I override existing settings that may be affecting new ones applied?
Dan
Pingback from markwilson.it » Customising a Cisco 79xx IP Phone: directory services
Time: Thursday 17 September 2009, 16:20
[...] up, you need a web server with PHP installed (I used PHP 5.2.6 on IIS 6.0). This also needs the LDAP extension to be enabled by uncommenting extension=php_ldap.dll in [...]


Write a comment
Please note the rules for comments and the privacy policy and data protection notice. I'm sorry but, because not everyone sticks to the rules, I've had to implement some spam prevention measures - if you're experiencing difficulties leaving a comment, please let me know.