Online Chat
 Call Us: 
1-877-744-1221
Browse Ask a Question
 
Advanced Search
Tools
Rss Categories

PHP installation on IIS6

Author: Edward Hardin Reference Number: AA-00491 Last Updated: 10/01/2013 02:08 PM 0 Rating/ Voters

This guide describes installation of PHP with FastCGI on IIS6 server.

We strongly recommend you to use the latest version of PHP (v5.3 or higher). Earlier versions of PHP for Windows have bugs and may freeze when launch external programs (e.g. attachment indexation plugins) using Windows command line.

Actual PHP versions work with IIS via FastCGI interface. We will explain how to install FastCGI and configure it to work with PHP.

Installing the FastCGI Extension for IIS 6.0

The FastCGI extension for 32bit and 64bit Windows XP and Windows Server 2003 can be downloaded from the official Microsoft website.

When you run FastCGI installer, it copies FastCGI specific files to "%WINDIR%\system32\inetsrv" folder (e.g. "C:\Windows\system32\inetsrv\") and then registers and enables FastCGI Web Server Extension. Out of the files that the installer copies, be aware of the following:

  • fcgiext.dll – This is the actual FastCGI handler that communicates with FastCGI enabled processes for processing requests
  • fcgiext.ini – This is the configuration file that contains mapping of file extensions to FastCGI processes. It also contains the configuration of FastCGI process pools.

Downloading and Installing PHP

  1. Download the latest PHP package for Windows 
    You need PHP v5.3 or higher. Choose ZIP package VC9 x86 Non Thread Safe.
    MSSQL

    If you're planning to use MSSQL as a database server, be sure download PHP v5.3.* (not v5.4.*!) as SQL drivers for PHP that work on IIS6 are available only for v5.3.* family. PHP v5.4.* drivers for SQL doesn't work on IIS6.

    If your database is MySQL you can use PHP v5.4.* without any restrictions.

  2. Extract the contents of PHP zip package to a folder on your server, e.g. C:\PHP\
  3. Make a copy of the php.ini-production file and name it php.ini
  4. Open the php.ini and setup the following parameters. Every parameter already exists in the php.ini and you just need to find it, uncomment (by removing ";" character from the beginning of the line), and change its value. Make sure that you do not have one of these options specified twice in the php.ini file.

    memory_limit = -1
    post_max_size = 128M
    extension_dir = "C:\PHP\ext"
    upload_tmp_dir = "C:\PHP\upload"
    upload_max_filesize = 128M

    max_execution_time = 600
    max_input_time = 600
    max_input_vars = 2000

    extension=php_curl.dll
    extension=php_mbstring.dll
    extension=php_exif.dll
    extension=php_gd2.dll
    extension=php_ldap.dll
    extension=php_mysqli.dll

    session.save_path = "C:\PHP\session"

    session.use_cookies = 1

    fastcgi.impersonate = 1
    cgi.fix_pathinfo = 1
    cgi.force_redirect = 0

    Extensions Loading Order

    It is required to load "php_mbstring.dll" extension before "php_exif.dll". Make sure that order of these two extensions in your php.ini is the same as shown above.

  5. Create "upload" and "session" sub-directories in the C:\PHP\ directory. You can use different names, just make sure that they match upload_tmp_dir and session.save_path parameters that you've set in the php.ini. 
  6. Setup date.timezone parameter in php.ini, for example:
    date.timezone = "America/New_York"

    Chose your city or at least a city from your time zone.

    You can find the full list of possible date.timezone values on PHP.net website.

  7. Save the php.ini.
  8. To test if the PHP installation is successful, run the following from the command line prompt:
    C:\PHP>php -i

    If PHP Fails to Start

    VC9 Versions are compiled with the Visual Studio 2008 compiler and have improvements in performance and stability. The VC9 versions require you to have the Microsoft 2008 C++ Runtime (x86)  or the Microsoft 2008 C++ Runtime (x64)  installed. You may need to download these extensions on old versions of Windows if PHP is unable to start.

Manually Configuring FastCGI Extension to Work with PHP

To manually configure the IIS and FastCGI extension, you must create script mappings for the PHP extension in the IIS metabase and modify fcgiext.ini file located in %WINDIR%\system32\inetsrv.

Create script mapping

  1. Launch inetmgr.exe.
  2. Double click the machine icon for the local computer.
  3. Right click on "Web Sites" and pick "Properties."
  4. Click the "Home Directory" tab. 
  5. Click the "Configuration…" button.
  6. Click the "Add…" button.
  7. Browse to the fcgiext.dll located in %WINDIR%\system32\inetsrv.
    Note: If you need to use FastCGI in 32 bit mode on a 64 bit machine, then browse to %WINDIR%\SysWOW64\inetsrv.
  8. Enter .php as the Extension.
  9. Enter Verbs as GET,HEAD,POST .
  10. Ensure that "Script Engine" and "Verify that file exists" are checked.



  11. Click OK

Modify fcigext.ini file

Once the script mapping is added, modify the fcgiext.ini file:

  1. Add an extension to application mapping (php=PHP) to the [Types] section.
  2. Add [PHP] section with ExePath=c:\php\php-cgi.exe (assuming you installed PHP files to C:\PHP folder).

[Types]

php=PHP


[PHP]

ExePath=c:\php\php-cgi.exe

RequestTimeout=600

ActivityTimeout=900

After all the changes to fcgiext.ini the file are saved, restart the web server.

Configure default document in IIS

Most of the PHP applications use a file named index.php as the default application document. Configure IIS to treat this file as the default content page:

  1. Launch inetmgr.exe.
  2. Double click the machine icon for the local computer.
  3. Right click "Web Sites" and pick "Properties."
  4. Click the "Documents" tab.
  5. Click the "Add…" button and enter "index.php" for "Default Document Name:" 
  6. Click "OK."

Testing PHP CGI

After installing the FastCGI extension, and registering and configuring the PHP CGI, you can use KMP normally.

Restart the IIS server to apply all changes that you've made.

To test, create and request an info.php page in your site that contains the following:

<?php
phpinfo();
?>

You see something like: 


Note that the Server API indicates that PHP is hosted in FastCGI mode.