PHP on IIS6 with MS SQL Server 2005

email famfamfam PHP on IIS6 with MS SQL Server 2005 Email This Post

Although I think that running PHP and MySQL applications on Linux is more natural and easy to be implemented, sometimes I am still asked to install PHP applications on Windows and use MS SQL Server as database.

My environment is:

  • Windows 2003R2 in VirtualBox
  • IIS 6
  • MS SQL Server 2005

1. Install PHP on IIS:
1.1 Download the PHP:

1.1.1 For the latest version of PHP for Windows, please go to:
http://windows.php.net/download/

1.1.2 For the older version of PHP, please go to:
http://www.php.net/releases/

Because I need to install ODBTP Database Connector to connect to MS SQL Server, and the ODBTP said that it only support several version of PHP including 5.1.1, I have to install PHP 5.1.1 instead of the latest version.

When you download, you need to select Windows binary.

1.2 Unzip the the file downloaded and rename move it to a folder under C drive called:
C:\php511

In case you want to test another version of PHP, you can download another one and name it as:
C:\php532 or similar. But you need to change other configuration as below to make it work.

1.3 Setup System Environment:
1.3.1 Right click “My Computer” and select “Properties”, or go to “Start” –> “Run” –> Type: sysdm.cpl, a “System Properties” window will pop up.

Select “Advanced” –> “Environment Variables”. At “System variables”, click “Path”, then click “Edit”, add “C:\php511″ (same as the path in above (2)) at the end. It should be like:
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\php511

The purpose of this variable is telling system the location of the PHP’s Dlls and Executable files.

1.3.2 You also need to add a new System variable here. Please click “New”, type the “Variable name” as “PHPRC”, “Variable value” as “C:\php511″.

The purpose of this variable is telling the location of php.ini (PHP Configuration File) to the system.

1.4 Install and Configure IIS Extension to run PHP:
There are 3 options to run PHP on IIS: CGI, ISAPI and FastCGI. Here is the comparison of the three:

Performance (from low to high): CGI < FastCGI < ISAPI
Stability (from low to high): ISAPI < FastCGI < CGI

It is very obvious that the FastCGI is the most balanced option. FastCGI is an IIS Extension provided by Microsoft to make IIS more supportive to PHP and other Open Source applications.

1.4.1 Download and Install FastCGI:

Go to: http://www.server7.iis.net/download/FastCGI to download the x86 or x64 version installation file according to your computer’s architecture.

Click the installation file fcgisetup_1.5_rtw_x86.msi and follow the instruction to install it.

1.4.2 Configure the FastCGI to make it work with the PHP you installed:

1.4.2.1 Web Service Extensions –> FastCGI Handler

Open your IIS Manager which is located in “Administrative Tools”, or you can just run “inetmgr”. In the “Web Service Extensions”, you will see a “FastCGI Handler” was already there, also it was “Allowed”. It should be always allowed, otherwise your PHP and FastCGI will not work.

php iis 5 PHP on IIS6 with MS SQL Server 2005

1.4.2.2 Add .php Application Extensions Mapping:

In the same IIS Manager, right click the “Web Sites”, select “Properties” –> “Home Directory” –> “Configuration” –> “Mapping”,


转载请注明出处,本文短链接地址:
Posted in Microsoft Tagged with: , , , , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

友情链接

“美国华人” (ChineseAmerican.org) 是一个立场中立、传播美国华人正能量的自媒体。其宗旨是:美国华人团结一心、关心政治、共同进步。