THE SQL Server Blog Spot on the Web

Welcome to - The SQL Server blog spot on the web Sign in | |
in Search

Davide Mauri

A place for my thoughts and experiences the Microsoft Data Platform

PHP Setup for IIS and SQL Server

Making PHP running on IIS and configuring it to be able to connect and query a SQL Server database is quite easy. If just need to get pointed to the correct direction, since information are spread all across the web but sometimes is not easy to understand to which version they apply.

So, since our primary goal is to have Wordpress 3.3.2 (the latest version as of 07 May 2012) and PHPBB 3.0.12 (the latest version as of 07 May 2012) up and running, we’ll download the latest PHP 5.3 version (PHP 5.4 has been reported to have some problems with the current version of Wordpress so we won’t go for the latest one).

So the first step is to download PHP 5.3.12 version from PHP.NET web site:

As you may notice there are tow flavor of the PHP distribution: Thread Safe and Non Thread Safe (NTS).

I’ve googled/binged a bit to understand what’s the advised flavor and as you can read here 

the best practice is to use the NTS flavor.

I downloaded the Zip package, and unzipped the files in a newly created PHP directory under C: drive (C:\PHP)

The above link also pointed me to a resource page very helpful for everyone trying to install PHP and configure on IIS:

The following link give also additional information

I also found a very nice IIS Add-on that allows you to manage PHP directly from IIS:

One installed the PHP Manager, you can check that everything is working simply checking that PHPINFO() works:



To be able to use SQL Server from PHP you need the PHP SQL Server Drivers provided by Microsoft:

Once the file has ben downloaded I extracted it to a C:\PHPSQLSRVfolder.

Now you must acknowledge PHP that they exists and should be used. You can do it directly modifying your <php install folder>\php.ini file, adding the reference to the extension,


begin sure to have copied the correct .dll file into the <php install folder>\ext folder.


if you have installed the PHP Manager, you can also enable/disable extension from here (.dll file must be manually copied into the /ext directory anyway)


As you may have noticed, after having unzipped the PHP SQL Server Drivers  you have a bunch of files to choose from. Which is the one right for you? For the configuration we’ve chosen we have to go for the “standard” (which means not the “pdo” driver), non-thread safe PHP 5.3 driver. As you can guess the file we need is


After having restarted your website, you can check in the phpinfo() page if the extension was loaded correcty:



I strongly suggest to take a look at the help file that comes with the PHP SQL Server Drivers, so that you can start to get used to access SQL Server from PHP. In particular use the code shown in the

“How to: Connect Using SQL Server Authentication”

help article in order to create a .php page to test that your environment can correctly connect to SQL Server.

Of course be sure to have at least the SQL Server Native Client installed on the web server, otherwise you won’t be able to connect to SQL Server from PHP.

That’s it! You now have a PHP environment on you IIS 7 / 7.5 capable of using SQL Server as RDBMS.

Published Monday, May 7, 2012 6:20 PM by Davide Mauri
Filed under: , , ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS



Davide Mauri said:

In the last months, in the spare time, I started to study PHP in order to use it on a Windows + SQL Server

May 27, 2012 10:15 AM

ricardo pereira said:

ótimo site parabens, Scriptcase é um bom site recomendo.

June 14, 2013 12:55 PM

abx said:


May 31, 2018 11:01 PM

dongdong8 said:



June 29, 2018 3:30 AM

linying123 said:


July 16, 2018 8:40 PM

dongdong8 said:



July 23, 2018 11:40 PM

chenjinyan said:


August 22, 2018 11:16 PM

shenyuhang said:


August 23, 2018 10:31 PM

chenlixiang said:



September 18, 2018 10:11 PM

chenjinyan said:


October 9, 2018 6:55 PM

chenqiuying said:


October 10, 2018 6:40 PM

chenlixiang said:


November 20, 2018 10:50 PM

yanmaneee said:">">

June 29, 2020 10:56 PM

Leave a Comment


About Davide Mauri

Director of Software Development & Cloud Infrastructure @ Sensoria, an innovative smart garments and wearable company. After more than 15 year playing with the Microsoft Data Platform, with a specific focus on High Performance databases, Business Intelligence, Data Science and Data Architectures, he's now applying all his skills to IoT, defining architectures to crunch numbers, create nice user experiences and provide meaningful insights, all leveraging Microsoft Azure cloud. MVP on Data Platform since 2006 he has a very strong background development and love both the ER model and OO principles. He is also a fan of Agile Methodology and Automation, which he tries to apply everywhere he can, to make sure that "people think, machines do".

This Blog


Privacy Statement