增加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电脑
关于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/
[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教程》