Installing a PHP application on Windows Server 2008 with IIS 7.0
Something that is new in server 2008 is the possibility of running PHP applications on IIS 7.0 in a more native way.
In this post I will try to run you through the way of setting this up.
First you have to add the Web Server role of course, be aware that you need to add the CGI role service. as shown in the following screenshot.
Download and extract PHP from here. (I will work with the ZIP version and I will Extract to d:PHP)
copy the file php.ini-recommended to php.ini and open it to edit the file.
The application i am going to install makes use of the le: php_gd2.dll so I have to register that file in the ini file, find the entry extension_dir = … and change it to extension_dir = "d:phpext"
Uncomment the line extension=php_gd2.dll
This is the configuration done at the PHP side.
Now to enable PHP in IIS:
Go to the webserver administration tool:
and click handler mappings
click add module mapping and fill out the form as show in the above screenshot. (the name field just refers to a name shown in the module mapping overview, so choose it according to your needs. when done click OK, a pop-up appears:
click Yes.
Now all you have to do is create your website and copy the php files to that webiste, maybe change the default document to fit your application. and you’re ready to run.
If needed (or wanted) you could also do the creation of the FastCGI handler from the commandline (with AppCmd.exe):
- Open a command prompt.
- Change directory to your InetSrv folder using the following syntax:
cd /d %systemroot%system32inetsrv - Add the PHP executable to the FastCGI settings using the following syntax:
appcmd set config /section:system.webServer/fastCGI /+[fullPath=’d:phpphp-cgi.exe’] - You receive the following response:
Applied configuration changes to section "system.webServer/fastCGI" for "MACHINE/WEBROOT/APPHOST" at configuration commit path "MACHINE/WEBROOT/APPHOST" - Add the PHP executable to the FastCGI settings using the following syntax:
appcmd set config /section:system.webServer/handlers /+[name=’PHP-FastCGI’,path=’*.php’,verb=’*’,modules=’FastCgiModule’,scriptProcessor=’c:phpphp-cgi.exe’,resourceType=’Either’] - You receive the following response:
Applied configuration changes to section "system.webServer/handlers" for "MACHINE/WEBROOT/APPHOST" at configuration commit path "MACHINE/WEBROOT/APPHOST"