2012/04/26

SQLSRV for PHP 5.4

Last month PHP 5.4 was recently released to some excitement in the community.  Stodgy old man that I am, I was happy to upgrade as soon as possible, but after the installation I found that Microsoft was not quite yet ready with a new set of drivers for SQL Server.  So I swapped back to the PHP 5.3 cgi and let time do it's work.

Fast forward a few weeks and I find that all of the pieces have happily produced themselves.  Here is a short rundown on installing the newest SQL Server drivers for PHP 5.4:



First off, the newest release of SQL Server for PHP (3.0.1) depends on the Microsoft SQL Server 2012 Native Client driver, an ODBC carbuncle that can be obtained from http://msdn.microsoft.com/en-us/library/cc296170.aspx.  Haha, gotcha, you actually have to get it from the Microsoft SQL Server 2012 Feature Pack page: skip the big red "Download" button that will do you no good at all, instead scroll down to find "Microsoft® SQL Server® 2012 Native Client" under the Connectivity Feature Pack Components.  Download the installer according to your OS (X64 in my case, save rant about stupid chipset designations for another time...)  Nothing fancy in the installation here, just click through the wizard and you save yourself an annoying error message.

If Microsoft built a car you would buy the body from Dell, the wheels from Best Buy, and the installer manual  from Xbox Live, only 1000 points!
Now we can install the Microsoft Drivers 3.0.1 for SQL Server for PHP.  Download the SQLSRV30.EXE to get the PHP 5.4 drivers.  After downloading and running the installer it will extract four sets of drivers (save these somewhere easy like the Desktop).  The drivers are grouped by PHP 5.3 (thread-safe and non) and 5.4 (thread-safe and non).  You can find out if your PHP is thread-safe or not by launching phpinfo(), but it's more than likely not so grab php_sqlsrv_54_nts.dll and it's companion php_pdo_sqlsrv_54_nts.dll and move these files into the /ext directory under your PHP installation (mine is C:\Program Files (x86)\PHP\v5.4\, YMMV).  The temporary directory and remaining drivers can be deleted now.

Lastly, open IIS Manager and under the Server settings open PHP Manager.  Verify the PHP Version is the 5.4 cgi.  Click on Enable or disable an extension at the bottom of the panel.  In the extensions menu locate pdo_sqlsrv and sqsrv drivers in the Disabled list (they may need to be added manually, but should appear automatically).
You can do this in php.ini, of course, but manually editing text files is for that other system.

Enable both drivers and open phpinfo() in a browser window to confirm they were added correctly.  And with that we've got a brand new, shiny, up-to-date WISP server.  What's that you say?  PHP 5.4.1 came out today?

No comments:

Post a Comment