[PHP-users 3508] Re: Linux+php4から内部のMS SQLサーバーへの接続について

Keishi Kawakami php-users@php.gr.jp
Tue, 13 Nov 2001 13:12:53 +0900


説明が足りず、どうもすみませんでした。
以下の記事をもとに設定いたしました。

Building PHP as a DSO for Apache 1.3.22 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.22 
* FreeTDS 0.53
* 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.22.tar.gz | tar -xf - 
cd apache_1.3.22 
./configure --prefix=/usr/local/apacheso --enable-module=so 
make && make install 

(2) Build Freetds 
tar -xzvf freetds-0.51.tgz 
cd freetds-0.53
./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 'tdsdbopen' 
(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!