linux下php加装mssql模块的方法
来源:互联网 发布:有百合网源码卖 编辑:程序博客网 时间:2024/05/21 15:38
http://www.jb51.net/article/27018.htm
其他模板扩展类型
在linux 下的php连接mssql,就需要安装第三方的freetds了。需要的朋友可以参考下。
1、安装配置freetds
wget http://mirrors.xmu.edu.cn/ubuntu/archive/pool/main/f/freetds/freetds_0.82.orig.tar.gz
tar zxf freetds_0.82.orig.tar.gz
cd freetds_0.82
./configure --prefix=/usr/local/freetds --with-tdsver=8.0 -–enable-msdblib -–enable-dbmfix -–with-gnu-ld -–enable-shared -–enable-static
make && make install
2、编译php的mssql模块
cd /path/to/php/source 进入PHP源码目录
cd ext/mssql 进入MSSQL模块源码目录
/usr/local/webserver/php/bin/phpize 生成编译配置文件
./configure –with-php-config=/usr/local/webserver/php/bin/php-config –with-mssql=/usr/local/freetds
make
make install
编译完成生成 mssql.so,修改php.ini,将该模块载入:
extension=”/path/to/extension/mssql.so”
3、配置mssql
cd /usr/local/freetds/etc
编辑文件:
vi 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
client charset = UTF-8 #加入
#加入
[Server2005]
host = 192.168.x.x
port = 1433
tds version = 7.2
4、测试php连接mssql
<?php
try {
$hostname='218.x.x.x';//注意,这里和上面不同,要直接用IP地址或主机名
$port=1433;//端口
$dbname="user";//库名
$username="database";//用户
$pw="passwd";//密码
$dbh= new PDO("dblib:host=$hostname:$port;dbname=$dbname","$username","$pw");
} catch (PDOException $e) {
echo"Failed to get DB handle: ".$e->getMessage() ."n";
exit;
}
echo'connent MSSQL succeed';
$stmt=$dbh->prepare("select * from z_2010pinjiu_user");
$stmt->execute();
while ($row=$stmt->fetch()) {
print_r($row);
}
unset($dbh); unset($stmt);
?>
复制代码 代码如下:
wget http://mirrors.xmu.edu.cn/ubuntu/archive/pool/main/f/freetds/freetds_0.82.orig.tar.gz
tar zxf freetds_0.82.orig.tar.gz
cd freetds_0.82
./configure --prefix=/usr/local/freetds --with-tdsver=8.0 -–enable-msdblib -–enable-dbmfix -–with-gnu-ld -–enable-shared -–enable-static
make && make install
2、编译php的mssql模块
复制代码 代码如下:
cd /path/to/php/source 进入PHP源码目录
cd ext/mssql 进入MSSQL模块源码目录
/usr/local/webserver/php/bin/phpize 生成编译配置文件
./configure –with-php-config=/usr/local/webserver/php/bin/php-config –with-mssql=/usr/local/freetds
make
make install
编译完成生成 mssql.so,修改php.ini,将该模块载入:
extension=”/path/to/extension/mssql.so”
3、配置mssql
复制代码 代码如下:
cd /usr/local/freetds/etc
编辑文件:
vi 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
client charset = UTF-8 #加入
#加入
[Server2005]
host = 192.168.x.x
port = 1433
tds version = 7.2
4、测试php连接mssql
复制代码 代码如下:
<?php
try {
$hostname='218.x.x.x';//注意,这里和上面不同,要直接用IP地址或主机名
$port=1433;//端口
$dbname="user";//库名
$username="database";//用户
$pw="passwd";//密码
$dbh= new PDO("dblib:host=$hostname:$port;dbname=$dbname","$username","$pw");
} catch (PDOException $e) {
echo"Failed to get DB handle: ".$e->getMessage() ."n";
exit;
}
echo'connent MSSQL succeed';
$stmt=$dbh->prepare("select * from z_2010pinjiu_user");
$stmt->execute();
while ($row=$stmt->fetch()) {
print_r($row);
}
unset($dbh); unset($stmt);
?>
0 0
- linux下php加装mssql模块的方法
- linux下php加载mssql模块
- linux下添加php的mssql扩展
- Linux下PHP支持MSSQL
- PHP下如何新加模块
- Linux下PHP支持MSSQL(SQL Server2000)
- Linux下PHP支持MSSQL(SQL Server2000)
- linux下 安装php的gettext模块
- linux下快速编译模块的方法
- PHP连接mssql的一些方法总结
- php调用MSSQL存储过程的方法
- IIS+MSSQL+PHP的配置方法
- IIS+MSSQL+PHP的配置方法
- php连接mssql方法
- linux(fedora)下freetds编译安装及编译php的mssql扩展
- LINUX下php连接mssql数据库中文字符乱码问题解决
- Linux下php访问远程mssql server
- 悬而未决:LINUX下的PHP不支持com_dotnet模块?
- myeclipse 不提示
- 在SQLite中使用事务
- YII2前端资源Assets
- 电脑上同时安装jdk1.7和jdk1.8时,转换jdk版本失效
- java web环境搭建
- linux下php加装mssql模块的方法
- 【LeetCode刷题记录】Pascal's Triangle
- 关于hibernate中的一些字段的解释@Transien
- 微营销好标题之情不自禁(微营销标题吸引粉丝篇-3)
- hdoj 2124 Repair the Wall
- Android百度地图学习笔记(一)
- Java反射--通过反射了解集合泛型的本质
- 【SQL Server 2008商务智能BI】数据挖掘导论
- Tomcat实现虚拟目录映射的方法