Archive for the ‘PHP’ Category

Install FastCGI

Install the Fast CGI for IIS 6.0

FastCGI is a language-independent extension to the Common Gateway Interface (CGI) that enables Web servers to execute applications more quickly and efficiently. Unlike CGI, which creates a separate process for each incoming request, FastCGI uses a single process to handle multiple requests. IIS uses FastCGI to support the popular PHP scripting language, which makes it one of the more important features of the product.

Download the FastCGI extension for 32-bit and 64-bit Windows XP and Windows Server 2003 here:


When you run the FastCGI installer, it copies FastCGI-specific files to the ”%windir%\system32\inetsrv” folder, and then registers and enables the FastCGI Web server extension. Of the files that the installer copies, note 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 the mapping of file extensions to FastCGI processes. It also contains the configuration of FastCGI process pools.
  • fcgiconfig.js – This configures the FastCGI extension. The script updates the fcgiext.ini file, modifies the IIS metabase and recycles the Web service application pools if necessary.

To configure the FastCGI extension to work with PHP:

  1. Open a command prompt.
  2. Change the current directory to %windir%\system32\inetsrv.
  3. Register the PHP CGI program as the one that will be processing .php extensions by running the following configuration script.

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

Script mappings for the PHP extension in the IIS metabase, and modify the fcgiext.ini file that is located in %windir%\system32\inetsrv.

To create script mapping:

1. Launch inetmgr.exe.
2. Double-click the machine icon for the local computer.
3. Right-click Web Sites and click Properties.
4. Click the Home Directory tab.
5. Click the Configuration… button.
6. Click the Add… button.
7. In the Add/Edit Application Extension Mapping dialog box, click Browse…. Navigate to the fcgiext.dll file that is located in %windir%\system32\inetsrv.
Note: If you need to use FastCGI in 32-bit mode on a 64-bit machine, navigate to %windir%\SysWOW64\inetsrv.
8.  In the Extension text box, enter .php.
9.  Under Verbs, in the Limit to text box, enter GET,HEAD,POST.
10.  Ensure that the Script engine and Verify that file exists check boxes are selected.
11.  Click OK.

FastCGI Configuration for Optimal Functionality, Security, and Performance with PHP

IIS identified the set of configuration settings for the FastCGI extension and PHP that would provide optimal functionality and performance for PHP applications when running on Windows by using the FastCGI extension.

To obtain optimal functionality and performance, configure your server as follows:

1.  Modify the php.ini file as follows:
* Set fastcgi.impersonate = 1. FastCGI under IIS supports the ability to impersonate the security tokens of the calling client. This allows IIS to define the security context under which the request runs.
* Set cgi.fix_pathinfo=1. cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI. Previously, PHP behavior was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not define PATH_INFO. For more information about PATH_INFO, see the cgi specifications. Setting this value to 1 will cause PHP CGI to fix its paths to conform to the specification.
* Set cgi.force_redirect = 0.
2.  Set the FastCGI configuration settings for the PHP section by running fcgiconfig.js as follows:
* Set the FastCGI process pool property InstanceMaxRequests to 10000. This setting specifies that the FastCGI extension will recycle php-cgi.exe after it has processed 10000 requests successfully.
> cscript fcgiconfig.js -set -section:”PHP” -InstanceMaxRequests:10000

3.  Configure the FastCGI extension to set the PHP_FCGI_MAX_REQUESTS environment variables for the PHP process to 10000.This setting instructs php-cgi.exe to recycle itself after it has processed 10000 requests successfully.
> cscript fcgiconfig.js -set -section:”PHP” -EnvironmentVars:PHP_FCGI_MAX_REQUESTS:10000

To test the PHP application, create and request a info.php


Read Full Post »

1. Choosing which package to download.

Packages can be downloaded from the following page:


2. Installing the Package

Figure 1 -Selecting Standard Installation
Figure 1 -Selecting Standard Installation

Despite what you might expect, the “Advanced” installation offers little over the “Standard” so it’s best to simply go for standard. Don’t worry about the “Mail Configuration” unless you know what you’re doing – just click “Next”.

Figure 2 -Selecting IIS6 Installation
Figure 2 -Selecting IIS6 Installation

Obviously, if you’re installing onto Windows Server 2003, you need to change the selection to “Microsoft IIS 6 or higher” and click “Next”.

A small box will appear to tell you that “IIS has been configured”. Press “OK”.

Figure 3 - Windows Script Host (ignore it)
Figure 3 – Windows Script Host (ignore it)

Closely followed by Figure 3 above (just ignore it and click “OK”)

Figure 4 -Registering CScript (Click "No")
Figure 4 -Registering CScript (Click “No”)

As VBScript has nothing to do with PHP just click “No” when Figure 4 (above) appears.

A couple of OK’s later, PHP is installed. Well, not quite.

3. Configuring Internet Information Services (IIS) Manager:

Figure 5 - Web Service Extensions
Figure 5 – Web Service Extensions

If you are using the new style Start menu, you can reach the Internet Information Services console by clicking “Start”, “Administrative Tools” and selecting “Internet Information Services (IIS) Manager” from the list.

If you are using the “Classic” style Start Menu, you can reach the console by clicking “Start”, “Programs”, “Administrative Tools” and select “Internet Information Services (IIS) Manager” from the list.

We need to configure “Web Service Extensions” so right-click on “Web Service Extensions” in the menu on the left. Then select “Add a new Web service extension…” from the list (as shown in Figure 5 above)

Figure 6 - Creating a PHP web service extention
Figure 6 – Creating a PHP web service extension

Complete the dialogue box as shown in Figure 6 (above). Make sure you check the “Set extension status to Allowed” checkbox. The “Extension name:” is only a reference and hence can be anything – PHP makes it easy to identify in future though.

Figure 7 - The completed Web Service Extensions window
Figure 7 – The completed Web Service Extensions window

The completed “Web Service Extensions” window should now look like figure 7

4. Allowing index.php files to run as a directory default:

Figure 8 - Configuring your default PHP content page
Figure 8 – Configuring your default PHP content page

In “Internet Information Services (IIS) Manager”, left-click on “Web Sites” in the menu on the left and select “Properties” (as shown in Figure 8 above). Next, select the “Documents” tab and click on “Add”.

Figure 9 - Configuring your default PHP content page
Figure 9 – Configuring your default PHP content page

To ensure that index.php documents open as a default they should be added as a “Content Page” as shown in Figure 9 (above). You can, of course, change the importance of PHP over ASP and HTML documents to suit your site based on which document type should take preference. This can be achieved by moving “index.php” up or down the list using the “Move up” and “Move Down” buttons.

5.The Final Step – Moving the php.ini file:

For some reason, the Installer copies it’s php.ini file into the “Windows” directory under the profile of the logged-on user rather than the root directory C: (where it should be).

  • Copy “php.ini” from C:\Documents and Settings\<username>\php.ini to C:\Windows

If you can’t find “php.ini” simply open “My Computer”, right-click on your C: drive and select “Search” from the list. Then type php.ini into the “All or part of the file name” box and press “Search”. The file that appears in the right-hand side of the window should be copied into C:\Windows.

6. Some Exceptional steps to configuration.

Open both the php.ini file you have now and uncomment cgi.force_redirect in php.ini and set it to 0 – zero.

Find SMTP = localhost and make sure it is uncommented. If your mail server is somewhere else you may specify it here. Also set this line just below the above: sendmail_from = someone@yourhost.com

Change session.save_path as “session.save_path=C:\php\sessions” and make the directory C:\php\sessions

Set the line “extension_dir” as “extension_dir = “C:\PHP\ext”.

Uncomment all of the following items.

Now copy all of those DLL files in C:\php\ext to C:\windows\system32 or add “C:\PHP;” to your Windows path.
To add php to your Windows path:

  1. Right Click on My Computer and choose properties > Advanced Tab > Click “Environment Variables”.
  2. Now add “C:\PHP;” to the very beginning.
  3. Now go to start > run > type: regedit and click ok
  4. Add HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath = C:\php to the registry. If you change your windows path instead of copying the dll files then you will need to restart your computer before php will work. Updating php is easier when you add it to your Windows path.

Figure 9 - Creating the required registry keys and values
Figure 9 – Creating the required registry keys and values.

Open the Registry Editor by clicking “Start”, “Run”, typing “regedit” and pressing “OK”. Perform the following procedure (illustrated by Fig. 9 above):

  • Locate and expand “HKEY_LOCAL_MACHINE”, right-click on “Software” and select “New”, “Key” and type “FASTCGI”.
  • Right-click on your new “FASTCGI” key and select “New”, “Key” and type “.php”.
  • Right-click on “.php”, select “New”, “String Value” and type “AppPath”. Double-click on this new value and type “c:\PHP\php.exe”.
  • Right-click on “.php”, select “New”, “String Value” and type “BindPath”. Double-click on this new value and type “php-fcgi”.

You can now close the Registry editior.

  • Go to C:\Inetpub\wwwroot and delete everything in there except for aspnet_client. Now make a new text file and name it phpinfo.php. Open it up with your text editor ant put this in it: <?php phpinfo(); ?>.
  • Open a web Browser and go to

Read Full Post »