php编译freetds,Linux 下 PHP 5.2.x 连接 SQL Server 数据库 FreeTDS 配置笔记

CentOS 5.4 Linux 下的 PHP(FastCGI) 需要连接相关部门的SQL Server 2000数据库,配置了扩展FreeTDS扩展。

1、编译安装FreeTDS

mkdir -p /data0/software/

cd /data0/software/

wget ftp://ftp.ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable.tgz

tar zxvf freetds-stable.tgz

cd freetds-0.82/

./configure --prefix=/usr/local/webserver/freetds --with-tdsver=8.0 --enable-msdblib

make && make install

cd ../

echo "/usr/local/webserver/freetds/lib/" > /etc/ld.so.conf.d/freetds.conf

ln -s /usr/local/webserver/freetds/lib/libsybdb.so.5.0.0 /usr/local/webserver/freetds/lib/libsybdb.so.4

/sbin/ldconfig

rm -f /usr/local/webserver/freetds/etc/freetds.conf

vi /usr/local/webserver/freetds/etc/freetds.conf

输入以下内容:

引用

[global]

# TDS protocol version

;       tds version = 4.2

# Whether to write a TDSDUMP file for diagnostic purposes

# (setting this to /tmp is insecure on a multi-user system)

;       dump file = /tmp/freetds.log

;       debug flags = 0xffff

# Command and connection timeouts

;       timeout = 10

;       connect timeout = 10

# If you get out-of-memory errors, it may mean that your client

# is trying to allocate a huge buffer for a TEXT field.

# Try setting 'text size' to a more reasonable limit

text size = 64512

host = mssql.yourdomain.com

port = 1433

tds version = 8.0

client charset = UTF-8

2、编译安装PHP自带MSSQL扩展

进入本地已存在的php-5.2.XX源码包目录:

cd /data0/software/php-5.2.XX/ext/mssql/

/usr/local/webserver/php/bin/phpize

./configure --with-php-config=/usr/local/webserver/php/bin/php-config --with-mssql=/usr/local/webserver/freetds/

make && make install

3、在php.ini配置文件中增加mssql.so

vi /usr/local/webserver/php/etc/php.ini

增加一行:

引用

extension = "mssql.so"

4、重启PHP FastCGI

/usr/local/webserver/php/sbin/php-fpm restart

5、测试文件(test_mssql.php):

66f96b77d61b8b635c3df12e4bbb2fe1.png

c4179c6e8156ba3ccf927ac529d343c7.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值