I have found some articles in PHP.NET and Linux Journal (using unixODBC), but the only way to get it to work right was by installing freetds as follows:
First, get the latest stable versions for freetds, apache and php (yes, you will have to recompile php, and apache if you have installed it from the RPMs):
freetds-0.61.tgz
httpd-2.0.47.tar.gz
php-4.3.2.tar.bz2
Install FreeTDS:
cd freetds-0.61
./configure --enable-msdblib
make
make install
cd..
Install Apache:
tar -zxf httpd-2.0.47.tar.gz
cd httpd-2.0.47
./configure --enable-so
make
make install
cd ..
Install PHP:
tar -jxf php-4.3.2.tar.bz2
cd php-4.3.2
./configure --with-apxs2=/usr/local/apache2/bin/apxs
--with-mssql=/usr/local
make
make install
cp php.ini-dist /usr/local/lib/php.ini
Make sure apache is properly configured to load PHP:
vi /usr/local/apache2/conf/httpd.conf
Make sure the following two lines exist
LoadModule php4_module modules/libphp4.so
AddType application/x-httpd-php .php
Presto!. Now start your apache with /usr/local/apache2/bin/apachectl start, and here is some php sample code:
<?php
# Replace your MS SQL Server IP address, username and password below
$link = mssql_connect("192.168.1.10:1695", "phptest", "phptest");
# A query string
$res1 = mssql_query("SELECT * from phptest", $link);
$rs = mssql_fetch_row($res1);
print "Here is your MS SQL data: $rs[0]";
mssql_close($link);
?>
Enjoy,
Julian