Another prerequisite: we want to use the most recent available versions for all involved products.
(it's February 2010 so we are using Apache 2.2.14, php 5.3.1, w2008SR2).
I will try to point out some of the points that you may stumble upon (used apache/php/sqlsrv file-versions, comparison of mssql_* vs. sqlsrv_* driver functions, specific issues with the sqlsrv_* functions) in several blog posts over the next few weeks.
So let's go.
You may have noticed that the php_mssql.dll driver on windows does no longer work with php 5.3 or higher and even with php 5.2.11 (upon apache start you get these typical "file not found" errors that just point out that the module can not be loaded for some reason.
It has not been forgotten and it will not come back in a next version afaik.
Basically you have 3 options:
- You can give up here and switch back to php 5.2.10 or an older version. And I definitely advise you to do so if you don't want to get in lots of troubles...
- switch the webserver part of your application to linux: if you use the freetds driver (that just replaces the original mssql_* functions 1:1) you are done and you will have advanced sql server functionality in this driver (utf8 support etc.).
- rewrite your application to use the new and opensource sql-server-driver for php that was written by Microsoft (you are reading right here, MS is writing an opensource driver for php)! The thing is: They dont' just take over the mssql_* functions like freetds does. The functions all start with 'sqlsrv_'. And they have (in some cases) completely different semantics. It's not just a search and replace work, it's a lot to do!
- We are not talking about php database abstraction layers for php (DBA, ODBC, PDO, whatever) and functions here. But this may also be an option for you.
First issue: Installing the Server environment
So you download the latest apache from an apache mirror, download php, the sql server driver and start?
Uhm... not really. Let's see:
- We will start by downloading php binaries.
But wait: For php 5.3 there are 12 different possible files to download. And they are all x86? So wich is the right one?
If you prefer the installer, the zip or the debug-zip is a personal-flavour thing (unless you are developing php itself I don't recommend the debug-zips). I use a zip-File, because I want as much control as possible.
We will use a VC9 file. That means: it has been compiled using visual studio 2008 (the most recent Visual Studio version). This is very important to keep in mind for later! - Now we need to find an apache binary that will work with the downloaded php version.
I recommend to try apachelounge, (read the first sentence on the donwload page wich states, that the donwloadable binary is compiled with VC9 also, but the original apache binaries from apache.org are still compiled with VC6!) - Now we go to the MS Download page to get the SQL Server driver for PHP binary. The current version is 1.1.
- The SQL Server driver for php is actually just a wrapper for the SQL Server Native Client database connector driver. So we need the Native Client driver as well. There is a standalone version available, but if you are running the DB (SQL Server 2005 or higher) on the same host you already have this component installed. For all others: Download it from the SQL Server 2008 Feature pack download page (scroll down to "Microsoft SQL Server 2008 Native Client"). You can use the x86 or the 64 bit version. I will use the 64bit sqlncli.msi (be careful if you download both: there is no difference in the file name!)
- Now as we are using software that has been compiled using Visual Studio, we need the right version of the VC runtime environment: Microsoft Visual C++ 2008 Redistributable Package (x86)
- and (if you have downloaded the 64-bit Native client) the Microsoft Visual C++ 2008 Redistributable Package (x64) as well (!).
Be sure to not mix up the different versions (there are also 2005- Versions and 2008 SP1 versions available - but these do not work in our environment)! Again: the download filenames are the same (vcredist_x64.exe / vcredist.exe for all versions), so be careful!
And install the components.
Now you can install the apache, include php and load the (right) sql server driver file via php.ini. According to what we have downloaded we will use the VC9 thread safe php 5.3 file, that is extension=php_sqlsrv_53_ts_vc9.dll
Maybe use the absolute path to where you unzipped the files.
If you now run php info, you will get the
sqlsrv support enabled
block somwhere at the end.
That's it for today. Next time we are comparing the availabe functions (sqlsrv vs mssql).
One short note: I will not be able to give support (unless you pay me for). However if you post a comment, other people may know the answer and post it as comment as well.

No comments:
Post a Comment