Install PHP and FastCGI Support on Server Core

by IIS Team

Introduction

FastCGI is a language-independent, scalable, open extension to Common Gateway Interface (CGI) that improves performance. The FastCGI extension is installable onto Server Core and enables application frameworks such as PHP to achieve improved performance and stability on Internet Information Services 7 (IIS 7) and above. Installing FastCGI when hosting PHP applications is very strongly recommended. In this example, we install FastCGI support to prepare the server to host our PHP application.

Install FastCGI Support

  1. To install FastCGI and Static Content Web Server support, type the following text into the Server Core system's command line, and then press ENTER:

    Start /w ocsetup IIS-WebServerRole
    
  2. Type the following text into the Server Core system's command line and press ENTER:

    Start /w ocsetup IIS-CGI
    
  3. AppCmd.exe is the command-line tool included with IIS. AppCmd.exe can be found in the %WinDir%\System32\InetSrv directory. Use AppCmd.exe commands to create the PHP/FastCGI handler mapping from the Server Core's command line (note that this is case sensitive):

    AppCmd set config /section:system.webServer/fastCGI /+[fullPath='d:\php\php-cgi.exe']
    
    AppCmd set config /section:system.webServer/handlers /+[name='PHP-FastCGI',path='*.php',verb='*',modules='FastCgiModule',scriptProcessor='d:\php\php-cgi.exe',resourceType='Either']
    
  4. Depending on the PHP installation location, paths to executables on the hard disk may require updates. Note that the AppCmd.exe example commands above assume that PHP installation is in the D:\PHP directory.

Install PHP on IIS 7 and Above

  1. Download the latest PHP release.

  2. In the section titled "Windows Binaries," select the archive with the .zip file extension. Note that the Server Core lacks a graphical user interface (GUI), and has no Web browser.

  3. Uncompress the archive's contents to a location accessible by the Server Core system, which is likely to be a network file share.

  4. Create a directory in which to copy the uncompressed files, for example:

    %SystemDrive%\PHP
    
  5. Copy the entire contents of the PHP archive you uncompressed previously into the %SystemDrive%\PHP directory.

  6. Execute the following command:

    rename %SystemDrive%\PHP\PHP.INI-Recommended %SystemDrive%\PHP\PHP.INI
    

Test the PHP Configuration

  1. From the command line, start Notepad.exe. In the empty file, type or paste the following text:

    <?php phpinfo(); ?>
    
  2. Save the file as phpinfo.php to c:\inetpub\wwwroot\.

  3. From a connected computer, open a browser window, and go to http://%systemhost%/phpinfo.php.

  4. A page appears showing the PHP configuration.

    Screenshot of the P H P Configuration page. This page shows information on P H P Version five dot two dot four.
    Figure 1: PHP page

Note

This article updates IIS 7.0 and Above on Server Core by Tobin Titus, published on September 11, 2009.

See also