Monday, June 08, 2009

Installing PHP on IIS 7.0?

Installing PHP on IIS 7.0 (Vista) for the first time? It is quite a rollercoaster ride. I struggled for about 30 minutes and finally got around to solving it after quite a bit of googling around. Here's the easy way then:

  1. Download and extract the latest Windows ZIP package from: http://www.php.net/downloads.php. Don't download the installer.
  2. Extract the contents of the zip file to your web root folder. It would be something like C:\inetpub\wwwroot\PHP for example.
  3. Now, first rename the php.ini –recommended file to php.ini
  4. Open the php.ini file to edit
  5. Uncomment:
  • fastcgi.impersonate
  • cgi.fix_pathinfo
  • cgi.force_redirect
  • open_basedir – Put the physical php application path here withing double quotation marks. For example – "C:\intepub\wwwroot\php"
  1. Install Hotfix from: http://download.microsoft.com/download/3/0/c/30ce6281-59e5-4315-9d9f-0a14bec95bbf/Windows6.0-KB954946-x86.msu. You will be prompted for a restart at the end.
  2. Once the machine is back after the restart, open the IIS Manager (type inetmgr in your Start > Run). With the Home location selected, click on Handler Mappings.
  3. If FastCGIModule is already present, remove and once again click on Add Module Mapping and enter the following:

    Request Path: *.php

    Module: Select FastCGIModule (if this is not present follow the steps given in point 9 to follow)

    Executable: click the button with the "..." to browse to the location of your PHP app path – for example, "C:\intepub\wwwroot\PHP" and select the PHP-CGI.exe file

    Name: PHPViaFastCGI

  4. If the FastCGIModule is not present in the Module drop down, follow these steps:

    1) Go into "Modules" dialogue at the Home location,

    2) Choose the "Configure Native Modules" option on the right pane,

    3) Choose "Register" on the next window, and

    4) Insert "FastCgiModule" in the Name textbox and "%WINDIR%\system32\inetsrv\iisfcgi.dll" (Replace %WINDIR% with your Windows path. For example C:\Windows). Easier is to use the navigation button to navigate and select the file mentioned above.

Once these 9 steps are done, create a php file to check if it works. It should.. otherwise there must be something else that has gone nuts! J

Now, people who know me must be asking the big question – "Arun? PHP? Not .NET? What happened???" Well! Let us just say that it was a fortunate turn of events that occurred. J

No comments: