增加php mssql扩展的方法:1、下载freetds及php源码包;2、安装freetds;3、解压php源码包,并进入mssql扩展目录;4、生成configure;5、编辑php.ini文件,加入mssql扩展即可。

本文操作环境:linux5.9.8系统、php-5.2.17版、DELL G3电脑

怎么增加php mssql扩展?

php安装mssql扩展

关于freetds编译时with-tdsver参数

在FreeTDS 1.1版本之后,可以设置为auto,版本之前需要手动指定。

以前写过mssql模块安装,这次只是补充编译freetds时指定with-tdsver参数

1、下载freetds及php源码包

[root@VM_0_11_centos ~]# wget -c ftp://ftp.freetds.org/pub/freetds/stable/freetds-1.1.21.tar.gz
[root@VM_0_11_centos ~]# wget -c http://museum.php.net/php5/php-5.2.17.tar.gz

2、安装freetds

# 解压freetds源码包

[root@VM_0_11_centos ~]# tar zxvf freetds-1.1.21.tar.gz
[root@VM_0_11_centos ~]# cd freetds-1.1.21/

# 开始编译安装

[root@VM_0_11_centos ~]# ./configure --prefix=/usr/local/freetds --with-tdsver=7.3 --enable-msdblib
[root@VM_0_11_centos ~]# make && make install

3、编译mssql模块

# 解压php源码包

[root@VM_0_11_centos ~]# tar zxvf php-5.2.17.tar.gz

# 进入mssql扩展目录

[root@VM_0_11_centos ~]# cd php-5.2.17/ext/mssql/

# 生成configure

[root@VM_0_11_centos mssql]# /www/server/php/52/bin/phpize

# 开始编译

[root@VM_0_11_centos php-5.2.17]# ./configure  --with-php-config=/www/server/php/52/bin/php-config --with-mssql=/usr/local/freetds
[root@VM_0_11_centos php-5.2.17]# make && make install

4、编辑php.ini文件,加入mssql扩展,在 491 行下面添加(如果不会用vi编辑器,可直接将文件下载改完再传上去)

[root@VM_0_11_centos ~]# vi /www/server/php/52/etc/php.ini
extension_dir = "/www/server/php/52/lib/php/extensions/no-debug-non-zts-20060613/"
extension = mssql.so # 新增行

保存退出,重启php或者重启服务器。


怎么增加php mssql扩展