• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

在Linux中访问MSSQL(PHP版)

发布: 2007-7-02 21:50 | 作者: admin | 来源: | 查看: 12次 | 进入软件测试论坛讨论

领测软件测试网

Linux——IBM PC SERVER 330, RedHat 6.2,Apache 1.3.20 + PHP 4.0.6
Win2k Server——DELL 4400, SQL SERVER 7.0
任务:公司图书馆的数据库系统采用MSSQL,WEB服务器我选了LINUX(硬件老啊),为了给全体职工提供在线图书查询,需要在LINUX中增加PHP模块,访问MSSQL。
解决过程:
找啊找啊找啊找,找到下面这篇E文,很好,居然一把搞定。
但是,我仔细看了PHP 4.X给的E文MANUAL,发现PHP是有MSSQL数据库访问支持的,那就是用它的DBX,如果你成功安装了下面的Freetds,你可以这样配置编译PHP:
./configure --prefix=/usr/local/php --enable-dbx --with-mysql --with-apxs=/usr/local/apache/bin/apxs --with-mssql=/usr/local/freetds --with-sybase=/usr/local/freetds --with-gd
make && make install
呵呵轻松搞定,很愉快哦。不想下载安装Freetds?只用DBX??不用我教了吧:)


09-Jul-2001 08:57
Building PHP as a DSO for Apache 1.3.19 in Linux RedHat 6.0 to connect
to
WIN2000 Server running SQL Server 2000
========================================
What Do We Need:
================
* PHP Source 4.0.6
* Apache 1.3.19
* FreeTDS 0.51
* Dual Login Mode in SQL Server Enterprise Manager (Windows ONLY login
will
not work!)
Installation Procedure:
=======================
(1) Build Apache, enable Dynamic Shared Object (DSO)
gzip -dc apache_1.3.19.tar.gz | tar -xf -
cd apache_1.3.19
./configure --prefix=/usr/local/apacheso --enable-module=so
make && make install
(2) Build Freetds
tar -xzvf freetds-0.51.tgz
cd freetds-0.51
./configure --prefix=/usr/local/freetds --with-tdsver=4.2
--enable-dbmfix
make && make install
(3) Link Freetds library
edit /etc/ld.so.conf (or equivalant) add /usr/local/ftds/lib to
it
run ldconfig (located in /sbin/ldconfig in linux)
(4) Build PHP
gzip -dc php-4.0.6.tar.gz | tar -xf -
cd php-4.0.6
edit ext/sybase/config.m4, replace dbopen with dsdbopen
(in version 4.0.6 of PHP this in on line 27 of config.m4)
./configure --with-apxs=/usr/local/apacheso/bin/apxs
--with-mssql=/usr/local/freetds --with-sybase=/usr/local/freetds
--with-mysql --enable-track-vars
make && make install
cp php.ini-dist /usr/local/lib/php.ini (the location of this file
may differ for your installation)
(5) Hack PHP initialization file
edit /usr/local/lib/php.ini file, look for sybase.interface_file
directive
uncomment it and change the value to
"/usr/local/freetds/interfaces" (location where you installed
freeTDS)
(6) Hack freeTDS file
edit /usr/local/ftds/interfaces file, for MSSQL, you have to add
an entry like the following*:
mssqlconnection
query tcp tds4.2 IPADDRESS_OF_SQL_SERVER 1433
*Note: when writing PHP code, use the name
"mssqlconnection" for hostname,
so you would use something like:
$conn = "mssqlconnection";
$username = "myuser";
$password = "mypass";
$dbc = mssql_connect ("$conn",
"$username", "$password");
(7) Setup Apache httpd.conf file and run!
Do a check to see if everything is OK, by starting Apache.
Good LucK!!!
(作者:老顽童)

延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网