Navigation-Menus (Do Not Edit Here!)

Friday, December 30, 2011

PHP 5.x with IIS6 and FastCGI Installation Guide


PHP 5.x with IIS6 and FastCGI Installation Guide

Most how to guide and forum posts you get on a Google search is outdated after searching around the net for this i found this nifty detailed article on installing & configuring PHP on IIS

if you have already setup PHP using the installer available on PHP.net

then check your script mappings and the path variables. 

note : path should point to php-cgi.exe in your PHP installation folder


Prerequisites
  • IIS 6

Install PHP

  • Unpack the content of the zip archive into a folder of your choice, for example C:\PHP\
  • Copy the C:\PHP\php.ini-production to C:\PHP\php.ini
  • Open the php.ini,search for the following lines, uncomment them and make sure they look like these below.

1
 extension_dir = "C:\PHP\ext"

error_log="C:\inetpub\temp\php-errors.log"

3
 cgi.force_redirect = 0

4
 fastcgi.impersonate = 1

5
 fastcgi.logging = 0

cgi.fix_pathinfo=1

  • Install Microsoft 2008 C++ Runtime (x86)

Install FastCGI

  • Install FastCGI 1.5. Just follow the installation process 
  • Using the CMD prompt, go to C:\Windows\System32\inetsrv 
  • Execute the following commands (source)

cscript fcgiconfig.js -add -section:"PHP" -extension:php -path:"C:\PHP\php-cgi.exe"

cscript fcgiconfig.js -set -section:"PHP" -InstanceMaxRequests:10000

cscript fcgiconfig.js -set -section:"PHP" -EnvironmentVars:PHP_FCGI_MAX_REQUESTS:10000


Manually Create script mapping

Note: This may not be necessary,
  • Launch inetmgr.exe.
  • Double click the machine icon for the local computer.
  • Right click on Web Sites and pick Properties.
  • Click the Home Directory tab.
  • Click the Configuration… button.
  • Click the Add… button.
  • Browse to the fcgiext.dll located in %windir%\system32\inetsrv.
  • Enter .php as the Extension.
  • Enter Verbs as GET,HEAD,POST.
  • Ensure that Script Engine and Verify that file exists are checked

Configure the default document in IIS

Use the Internet Information Services Manager (IIS Manager) to configure the default document in IIS. Most of the PHP applications use a file named index.php as the default application document. (source)

  • Launch inetmgr.exe
  • Double click the machine icon for the local computer.
  • Right click Web Sites and pick Properties.
  • Click the Documentstab.
  • Click the Add… button and enter index.php for Default Document Name
  • Click OK.


Test the PHP installation

  • Create a file with the name phpinfo.php with the following line of content

             <?php phpinfo() ?>

  • Save it in the C:\Inetpub\wwwroot folder.

  • Go to your Internet Explorer and in the address bar type http://localhost/phpinfo.php