持有时候我们需要PHP连接SQL Server,在Windows平台下可以直接连,而在Unix/Linux下如何连接呢?因为Unix/Linux下没有SQL Server的驱动,那么我们就需要安装驱动,这个驱动就是FreeTDS——Unix/Linux下的Sybase/SQL Server驱动。
完整的安装步骤如下:
1、下载安装FreeTDS(目前最新稳定版本是0.82)
写道
wget http://ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-0.82.tar.gz
tar zxvf freetds-0.82.tar.gz
cd freetds-0.82
./configure --prefix=/usr/local/freetds --with-tdsver=8.0 --enable-msdblib
make
make install
2、重新编译PHP 5.2.11
写道
wget http://www.php.net/get/php-5.2.11.tar.gz/from/this/mirror
wget http://php-fpm.org/downloads/php-5.2.11-fpm-0.5.13.diff.gz
tar zxvf php-5.2.11.tar.gz
gzip -cd php-5.2.11-fpm-0.5.13.diff.gz | patch -d php-5.2.11 -p1
cd php-5.2.11/
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir=/usr --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr/local --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --disable-ipv6 --without-pear --with-sybase=/usr/local/freetds
make ZEND_EXTRA_LIBS='-liconv'
make install
第三步:配置freetds
vim /usr/local/freetds/etc/freetds.conf
具体配置见该文件中的说明
例:
[sqlserver]
host = sql_server_name_or_host_ip
port = 1433
tds version = 7.0
第四步:配置phpini文件
找到
;extension=mssql70.so
将注释;去掉成
extension=mssql70.so
分享到:
相关推荐
PHP安装连接SQLSERVER扩展方法 自己研究了好久弄出来的啊 希望有用对你
PHP连接SQLServer代码,包括一个中文探针,一个英文探针以及PHP连接SQLServer关键核心代码,具体教程可查看博客。
PHP的PDO连接SQLSERVER: 含全套工具: php5.4_x86_nts安装包 微软的SQLSRV拓展 微软的odbc驱动msodbcsql.msi 微软的sql客户端sqlncli.msi 配置好的php.ini 具体安装说明(原创亲测) 说实话这个得来很不容易,整整一天...
使用PHP连接sqlserver数据库的时候可能会遇到各种问题,小小总结了一下需要的扩展以及遇到问题的解决方式。
php 连接Sqlserver扩展
PHP连接sql server 数据库。 基本查询代码也写了,拿去直接用 经测试没问题,放心下载
之前连接了无数次,看了无数教程,说得非常非常复杂,但都都没连接成功,浪费我一整天。现在终于找到方法了,连接不上的童鞋,试试...ntwdblib.dll是连接SQL Server2005服务器的,上面两个文件版本必须与PHP版本相同。
php连接sqlserver数据库驱动
PHP连接sqlserver ODBC
Linux环境PHP5.5以上连接SqlServer2008 简单 查询sqlserver的数据库 表的信息 很容易上手 多种连接查询方法 简单 Linux环境PHP5.5以上连接SqlServer2008 简单 查询sqlserver的数据库 表的信息 很容易上手 多种连接...
SQLSRV30 PHP连接sql server2008 SQL Server Driver for PHP3.0 PHP自带的php_mssql.dll文件已经满足不了sql server2005及其以上版本的使用了。微软也随之发布了SQL Server Driver for PHP来做相应的支持。 其中...
PHP连接SQL Server完整教程,亲测绝对可用!
Linux Php连接SQLServer数据库
最近研究PHP, 发现在THINKPHP不错, 但是想用THINKPHP连接SQLSERVER数据库,才到这个文件,希望对大家有用
基于Linux下PHP连接SQL Server方法,可进行数据库等常用操作及查询
SQLSRV30 PHP连接sql server2008 SQL Server Driver for PHP3 0 PHP自带的php mssql dll文件已经满足不了sql server2005及其以上版本的使用了 微软也随之发布了SQL Server Driver for PHP来做相应的支持 其中SQL ...
软件及系统版本: Windows xp sp3 Iis5.1 Apache 2.2 Php 5.2 Sqlserver 2005
ubuntu14.04+php5.6环境下连接sqlserver2008扩展库 mssql.so+pdo_dblib.so,编译方法:http://blog.csdn.net/hanzengyi/article/details/52054862
php连接sqlserver 32和64位版本
这个里面说了具体php怎么样连接SqlServer数据库的操作