Installing PHP 5.3 in IIS 5.1

This guide is for Installing PHP 5.3 (Thread Safe) in IIS 5.1. I'm assuming you have IIS 5.1 already installed in your system and you will need to download the following files:

Install and Configure PHP 5.3

Extract the contents of the PHP 5.3 Non Thread Safe Zip package for Windows to "C:\PHP". This will be your PHP installation directory. Go to "C:\PHP" and create a folder named "temp".

Configure the php.ini File
    Inside C:\PHP, copy the "php.ini-development" file and rename it to "php.ini" and edit the file to Notepad. You need to configure the "php.ini" file by uncommenting by removing the semi-colon (;) and changing the values of the following:
      cgi.fix_pathinfo = 1
      cgi.force_redirect = 0
      fastcgi.impersonate = 1
      fastcgi.logging = 0

      extension_dir = "C:\PHP\ext"
      session.save_path = "C:\PHP\temp\"
      upload_tmp_dir = "C:\PHP\temp\"

      display_errors = On
      display_startup_errors = On
      log_errors = On
      error_log = "C:\PHP\temp\phperror.txt"

      extension = php_mysql.dll
      extension = php_mysqli.dll
      extension = php_curl.dll
      extension = php_gd2.dll
      extension=php_mbstring.dll

      Configure the Path Variable

      For PHP and its extensions to work properly, they need to access the DLLs present inside C:\PHP. The recommended method is to add "C:\PHP" to the Path Environment Variable. To do this Right-click on My Computer, click Properties and on the Advanced tab click Environment Variables. In the Environment Variables dialog box, under System variables highlight the Path variable and click Edit.




      Add ";C:\PHP" (be sure to include the semi-colon separator) as shown here and click OK. You need to re-boot the server for this change to take effect.



      Install and Configure FastCGI Extension

      Run the FastCGI Extension for IIS 6.0 and 5.1 Installer (fcgisetup_1.5_rtw_x86.msi) to copy the necessary files to your machine. The FastCGI Extension can be configured by editing the "fcgiext.ini" file which is located in "C:\WINDOWS\system32\inetsrv\" directory. Edit this file to Notepad and add the following:
      [Types]
      php=PHP

      [PHP]
      ExePath=C:\PHP\php-cgi.exe
      Arguments=-c C:\PHP\php.ini

      Install Microsoft Visual C++ 2008 Redistributable Package (x86)

      Run the Microsoft Visual C++ 2008 Redistributable Package (x86) (vcredist_x86.exe) to copy the necessary files to your machine.


      Configure IIS 5.1

      To route requests for PHP files to the FastCGI handler, you must associate .php files with the FastCGI Extension in IIS. This is done via Application Extension Mapping (also known as Script Mapping). Script maps associate file extensions with a script handler that executes when that file type is requested.
      1. Launch Internet Information Services (run inetmgr.exe).
      2. Expand the nodes in the left hand pane and locate Web Sites, right click on it and select Properties.
      3. On the Web Sites Properties windows choose Home Directory tab and click the Configuration... button.
      4. Make sure that the Application Mappings list does NOTcontain .php extension. Click the Add... button. Enter the following without the double quotes ("). Enter "C:\WINDOWS\system32\inetsrv\fcgiext.dll" as the Executable, enter ".php" as the Extension, limit the Verbs to "GET,HEAD,POST", and check the Script engine and Verify that file exists check-boxes.
      For your PHP applications to work smoothly, you should add "index.php", the default application document for most PHP applications, to the list of Default Documents. To do this here are the steps:
      1. Launch Internet Information Services (run inetmgr.exe).
      2. Expand the nodes in the left hand pane and locate Web Sites, right click on it and select Properties.
      3. On the Web Sites Properties windows choose Documents, and make sure that the Enable Default Document check-box is checked
      4. Click on Add... button, enter "index.php" (without the double quotes) as the Default Document Name and click OK.
      5. Close all dialog boxes by clicking OK.
      Before testing, restart IIS to make sure all configuration changes are applied. To do this click Start, click Run, type "cmd", and then click OK. At the command prompt, type "net stop iisadmin /y".


      Run phpInfo.php for testing

      Create "phpInfo.php" under "C:\Inetpub\wwwroot\" directory. Open the file at Notepad and type the following:
      <?php
      phpinfo();
      ?>

      Now open "http://localhost/phpInfo.php" in your browser to view the result. If all goes well, the phpinfo page should appear and you have successfully install PHP 5.3 in IIS 5.1! If you have any comments, questions about the installation and suggestions please feel free to post here.

      No comments:

      Post a Comment