1. FreeTDS must be installed
Installing the Pdo_dblib extension requires the installation of FreeTDS first.
FreeTDS's latest stable version is 0.91, this can be downloaded on the official website http://www.freetds.org/, can also be downloaded in http://download.csdn.net/detail/DLUTXIE/3663528
Download FreeTDS
wget ftp://ftp.freetds.org/pub/freetds/stable/freetds-stable.tgz
Tar zxf freetds-stable.tgz
CD freetds-stable/
/usr/bin/phpzie
./configure--prefix=/usr/local/freetds--with-tdsver=8.0--enable-msdblib
Make && make install
To configure the FreeTDS configuration file:
Host fills SQL Server address
Port Fill Ports
Tds version=8.0
Client charset = UTF8
3. Installing the Php_dblib module
/usr/local/php5/bin/phpize
Linking databases via Pdo_dblib
--with-pdo-dblib path refers to the installation path of the FreeTDS
./configure--with-php-config=/usr/local/php5/bin/php-config--with-pdo-dblib=/usr/local/freetds
Make
Make install
Add extension=pdo_dblib.so to the php.ini.
Then restart Nginx and PHP-FPM
[Email protected] no-debug-non-zts-20121212]#/etc/init.d/nginx restart
[Email protected] no-debug-non-zts-20121212]#/etc/init.d/php-fpm restart
See if there are pdo_dblib extensions in Phpinfo
4.pdo when connecting to the database:
Remember to use DBLIB instead of SQL Server
<?php
try{
$link =new PDO ("Dblib:host=souyue91;dbname=dbname", "Dbuser", "Dbpass");
}catch (Pdoexception $e) {
echo $e->getmessage ();
}
The host is filled with FreeTDS souyue91.
Linux-linked SQL Server database-driven installation