linux下配置连接mssql环境

简介:

 这里我们采用freeTDS程序库,实现linux下访问微软SQL SERVER数据库,php通过mssql.so库文件实现连接mssql

操作步骤如下:

       1.下载freeTDS

http://www.ibiblio.org/pub/Linux/ALPHA/freetds/old/0.63/freetds-0.63.tar.gz

tar xf freetds-0.63.tar.gz

./configure --prefix= --with-tdsver=8.0 --enable-msdblib --enable-dbmfix --with-gnu-ld

--enable-shared --enable-static

make && make install

(-prefix为设置FreeTDS的安装目录,--with-tdsver是设置TDS版本,--enable-msdblib为是否允许Microsoft数据库函数库)

       vim  /etc/profile

        中加入export PATH="$PATH:/usr/local/freetds/bin"

        source /etc/profile  是修改的系统变量生效

2.将freetds库加入系统库缓存

echo “/usr/local/freetds/lib”>>/etc/ld.so.conf

ldconfig命令使其生效

3、配置freetds(可省)

[root@ ~]# cat /usr/local/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 = xxx.xxx.xxx.xxx(mssql地址)

port = 1433
      tds version = 8.0
      client charset = UTF-8

4.增加mssql扩展

cd  /usr/src/lnmp/php-5.3.10/ext/mssql

/usr/local/bin/phpize

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

make && make install

ls  /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/mssql.so

vim /usr/local/php/etc/php.ini

添加extension=mssql.so

      测试:

<?php
$ms = mssql_connect('192.168.1.111,9201','usernanme','passwd',false);
var_dump($ms);
?>

本文转自    geekwolf   51CTO博客,原文链接:

http://blog.51cto.com/linuxgeek/1031718



相关文章
|
8天前
|
安全 Ubuntu Java
Linux配置使用篇
Linux配置使用篇
|
18天前
|
JSON Kubernetes Linux
Linux环境签发CA证书和K8s需要的证书
Linux环境签发CA证书和K8s需要的证书
22 0
|
20天前
|
存储 负载均衡 索引
linux7安装elasticsearch-7.4.0集群配置
linux7安装elasticsearch-7.4.0集群配置
108 0
|
25天前
|
监控 Linux Shell
【Shell 命令集合 网络通讯 】Linux 配置和管理网络流量的形状 shapecfg命令 使用指南
【Shell 命令集合 网络通讯 】Linux 配置和管理网络流量的形状 shapecfg命令 使用指南
36 0
|
25天前
|
网络协议 Shell Linux
【Shell 命令集合 网络通讯 】Linux 设置和配置PPP pppsetup命令 使用教程
【Shell 命令集合 网络通讯 】Linux 设置和配置PPP pppsetup命令 使用教程
33 0
|
25天前
|
Shell Linux C语言
【Shell 命令集合 网络通讯 】Linux 关闭PPP(Point-to-Point Protocol)连接 ppp-off命令 使用指南
【Shell 命令集合 网络通讯 】Linux 关闭PPP(Point-to-Point Protocol)连接 ppp-off命令 使用指南
38 1
|
25天前
|
域名解析 网络协议 Linux
【Shell 命令集合 网络通讯 】Linux 设置和管理网络接口配置信息 netconfig命令 使用指南
【Shell 命令集合 网络通讯 】Linux 设置和管理网络接口配置信息 netconfig命令 使用指南
45 1
|
5天前
|
存储 算法 Linux
【实战项目】网络编程:在Linux环境下基于opencv和socket的人脸识别系统--C++实现
【实战项目】网络编程:在Linux环境下基于opencv和socket的人脸识别系统--C++实现
17 6
|
25天前
|
存储 Shell Linux
【Shell 命令集合 系统管理 】Linux 修改用户的属性和配置 usermod命令 使用指南
【Shell 命令集合 系统管理 】Linux 修改用户的属性和配置 usermod命令 使用指南
30 1
|
7天前
|
网络协议 Linux
在Linux中,管理和配置网络接口
在Linux中管理网络接口涉及多个命令,如`ifconfig`(在新版本中被`ip`取代)、`ip`(用于网络设备配置)、`nmcli`(NetworkManager的CLI工具)、`nmtui`(文本界面配置)、`route/ip route`(处理路由表)、`netstat/ss`(显示网络状态)和`hostnamectl/systemctl`(主机名和服务管理)。这些命令帮助用户启动接口、设置IP地址、查看连接和路由信息。不同发行版可能有差异,建议参考相应文档。
17 4