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.