Home  >  Article  >  Database  >  Linux上连接Microsoft SQL Server 2005

Linux上连接Microsoft SQL Server 2005

WBOY
WBOYOriginal
2016-06-07 17:00:521088browse

RedHat 5.2系统上的需要使用PHP 连接Microsoft SQL Server 2005 数据库我们常见的连接数据库方式是使用ODBC方式连接,FreeTDS为Li

今天OA(RedHat 5.2)系统上的需要使用PHP 连接Microsoft SQL Server 2005 数据库,我们常见的连接数据库方式是使用ODBC方式连接,FreeTDS为Linux系统提供了TDS协议的开源客户端。由于MS SQL和Sybase使用的恰是TDS协议,所以在Linux中可以用FreeTDS连接MS SQL,,下面简绍使用php的db-lib连接Microsoft SQL Server 2005 数据库

1、下载FreeTds
cd /opt
wget

2、安装FreeTds
tar -zxvf freetds-stable.tgz
. /configure --prefix=/usr/local/freetds --with-tdsver=8.0 --enable-msdblib --enable-dbmfix --with-gnu-ld --enable-shared --enable-static
make
make install

3、编译php加上freetds
--with-mssql=/usr/local/freetds
注意:如果编译php加载freetds 时候出现不能找到freetds目录,则需要以下操作(官方的Faq)

touch /usr/local/freetds/include/tds.h
touch /usr/local/freetds/lib/libtds.a

4、测试
然后在网站根目录下 新建phpinfo.php测试页面如下:
phpinfo();  
?>  
使用浏览器打开
 

Linux上连接Microsoft SQL Server 2005

Linux上连接Microsoft SQL Server 2005

如果出现以上页面,证明php支持mssqlserver!

数据库连接测试页面:

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn