问题
Similar questions seem to be all over the internet, but so far nothing has helped.
I'm currently running WampServer with Apache 2.4.4 and PHP 5.4.12 on Windows Server 2008 R2. According to the PHP documentation the drivers necessary to connect to an MSSQL server ship with the distribution; they do not. Neither php_mssql.dll
(which the documentation claims is no longer necessary for PHP5.4, but which is still referenced in php.ini
. Who knows) nor php_pdo_mssql.dll
are present in the distribution.
Several sources pointed to these drivers from Microsoft, however I had no success either renaming the respective drivers to php_mssql.dll
/php_pdo_mssql.dll
or keeping the names the same (php_sqlsrv_54_nts.dll
, php_pdo_sqlsrv_54_ts.dll
, etc.) and modifying php.ini
to point to the proper driver. Though I didn't get an error upon starting apache as I do when the driver is simply missing, I received Error!: could not find driver
when attempting to point to a test php page at localhost.
This article seemed the most promising, but unfortunately ntwdblib.dll
is not included in the zip distributions of PHP, contrary to what the article claims. This seems like it should be a laughably simple problem: missing drivers, which are supposedly readily available. And yet here I am... What am I doing wrong?
回答1:
In case anyone else ends up here while trying to solve this problem, here are the steps that have worked for me the two times I've done it. These steps worked both on Windows Server 2008 R2 and Windows 8.
For my purposes, I used the latest 32-bit (x86) version of WampServer (at the time of this writing, it was 2.4, and came with Apache 2.4.4 and PHP 5.4.16). The 32-bit version is necessary, as the drivers are 32-bit; the 64-bit version will not work.
- Install Microsoft Visual C++ 2010 Redistributable Package x86
- Install Microsoft SQL Server 2008 Native Client x86 (Click "Download" and select
ENU\x86\sqlncli.msi
. Once again, the 64-bit version will not work) - Install Microsoft ODBC Driver 11 x86 (Click "Download" and select
1033\x86\msodbcsql.msi
) - Install Microsoft SQLSRV driver 3.0 in
php/ext/
(For my installation, this wasC:/wamp/bin/php/php5.4.16/ext/
) - Edit Apache's php.ini to include the line
extension=php_pdo_sqlsrv_54_ts.dll
(for my installation, this was located inC:/wamp/bin/apache/Apache2.4.4/bin/
)
回答2:
You have to place the file in the directory for PHP/ext (bin/php/ext depending on your Wamp / Xampp installation). However, you also need the SQL server native client as per: http://msdn.microsoft.com/en-us/library/cc296170.aspx
来源:https://stackoverflow.com/questions/20153869/error-could-not-find-driver-after-installing-php-pdo-mssql-dll-on-wampserv