1, installation configuration FreeTDS
Copy Code code as follows:
wget http://mirrors.xmu.edu.cn/ubuntu/archive/pool/main/f/freetds/freetds_0.82.orig.tar.gz
Tar zxf freetds_0.82.orig.tar.gz
CD freetds_0.82
./configure--prefix=/sxmobi/software/common/freetds--enable-msdblib
Make && make install
2, the compilation MSSQL extension, assumes the PHP installs the source code package for/usr/local/src/php-5.3.1
1 Enter the module source directory, >cd/sxmobi/web/softbak/php-5.3.13/ext/mssql
2 generate the compilation configuration file, >/sxmobi/software/webserver/php/bin/phpize
3) installation, >./configure--with-php-config=/sxmobi/software/webserver/php/bin/php-config--with-mssql=/sxmobi/ Software/common/freetds
4) >make
5) >make Install
6 Copy the generated mssql.so module to the extended directory of PHP, modify php.ini, add the MSSQL module
Note:
When compiling a configuration, you may encounter errors that cannot be found FreeTDS: Configure:error:directory/usr/local/freetds is not a FreeTDS installation Directory, According to the official explanation http://www.freetds.org/news.html
, PHP detects some files to determine if FreeTDS is installed, and because the new FreeTDS no longer installs these files, PHP compilation fails. Only two empty files can be created. As follows:
>touch/usr/local/freetds/include/tds.h
>touch/usr/local/freetds/lib/libtds.a
3. Modify/etc/freetds/freetds.conf
Copy Code code as follows:
[server2008]
Host = 192.168.0.109
Port = 1433
TDS Version = 7.0
Client CharSet = UTF8
4. Test connection
Copy Code code as follows:
./tsql-s 192.168.0.109-u User name-p password-d database
If you can see 1> the connection is successful
Enter SQL statement
1>select * FROM table;
2>go