Configuring PHP Support on IIS 7.0, Windows Server 2008, Windows 7

Configuring PHP Support on Windows Server 2008:

Click Start and select Server Manager under Administrative Tools.

Expand Roles.

Select the Web Server (IIS) role.

Web Server Roles

Click Add Role Services.

Select the CGI role service under Application Development.

Add Role Services

Click Next, then click Install.

Click Close when finished and close the Server Manager.


Configuring PHP Support on Windows 7:

Click Start and select Control Panel.

Click on Programs and select Turn Windows features on or off.

Expand Internet Information Server node, then expand Word Wide Web Services, and then Application Development Features.

Select the CGI feature under Application Development.

Windows Features

Click OK and proceed with the installation.

Close the Control Panel when finished.

Connecting to SQL Server through PHP

Your PHP Web applications can be deployed on the Windows platform with SQL Server by using of the SQL Server Driver for PHP. The driver is a Microsoft-supported extension of PHP 5 that provides a procedural interface for reading and writing data from within PHP scripts in all SQL Server 2005 and SQL Server 2008 editions (including SQL Server Express edition).

The SQL Server Driver for PHP API provides a comprehensive data access solution from PHP, and includes support for many features including Windows Authentication, transactions, parameter binding, streaming, metadata access, connection pooling, and error handling.

The following PHP code will create a sample connection to SQL Server TestDB using Windows Authentication through SQL Server Driver:

In order to execute this you need to have SQL Server Driver for PHP in place.

$serverName = “.\INSTANCE”;

$connectionInfo = array( “Database”=>”TestDB”);

$connection = sqlsrv_connect( $serverName, $connectionInfo);

if( $connection === false )


echo “Unable to connect”;

die( FormatErrors( sqlsrv_errors(), true));