linux下php连sql server2000
在一台linux的机器上使php(4.x)能够连sql server2000的数据库
apt-get install php-odbc unixODBC-devel unixODBC
或者是
yum install php-odbc unixODBC-devel unixODBC
然后再从这里(http://ibiblio.org/pub/Linux/ALP ... /freetds-stable.tgz)当下freetds的源码
cd /tmp
wget http://ibiblio.org/pub/Linux/ALP ... /freetds-stable.tgz
tar xzvf freetds-stable.tgz
cd freetds-*
./configure –prefix=/usr/local/freetds –with-tdsver=8.0 –with-unixodbc=/usr
(这里因为是连sql server2000,所以用“–with-tdsver=8.0”)
make;make install
vim /usr/local/freetds/etc/tds.driver.template
在文件中插入:
[FreeTDS]
Description = v0.64 with protocol v8.0
Driver = /usr/local/freetds/lib/libtdsodbc.so
(这里的freetds的版本是0.64)
然后安装driver
odbcinst -i -d -f /usr/local/freetds/etc/tds.driver.template
再然后建dsn吧
vim /usr/local/freetds/etc/tds.datasource.template
填写内容:
[MSSQLTestServer]
Driver = FreeTDS
Description = test sample database
Trace = No
Server = 192.168.1.1
Port = 1433
Database = testdb
再接着
odbcinst -i -s -f /usr/local/freetds/etc/tds.datasource.template -l
再重起apache
这会儿php就支持连sql server2000的库了。