Published February 17th, 2003 by Jim O'Halloran

PHP and MS SQL

It’s a LAMP site, but the M isn’t MySQL. Can PHP on the Linux box make the connection to Microsoft SQL Server?

The answer is am emphatic yes! A Linux Journal Article solves the problem, but uses UnixODBC to do it. I did this a while back with the help of this PHPBuilder article, which compiles PHP directly with MS SQL support. I compile FreeTDS as follows…

cd /usr/src/freetds
./configure --with-tdsver=4.2 \
    --enable-msdblib --enable-dbmfix \
    --with-gnu-ld --enable-shared \
    --enable-static --prefix=/usr/local/freetds
make
make install

Then compile PHP as follows…

cd /usr/src/php
rm configure
rm config.cache
./buildconf
./configure --with-mysql \
    --with-apxs2=/usr/local/apache2/bin/apxs \
    --with-sybase-ct=/usr/local/freetds
make
make install

My app has been in production for 4 or 5 months now with no problems.


0 Responses to “PHP and MS SQL”

Feed for this Entry
  1. No Comments

Leave a Reply

XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>