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??不用我教了吧:)
adam@netcominfo.com
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!!!
(作者:老顽童)