Skip to content
jcharaoui edited this page Oct 14, 2011 · 8 revisions

Libraries needed to connect to MS SQL on Debian.

Compilation of FreeTDS

This is required to be able to connect to servers using a recent MS SQL Server version. Skytech Clara uses SQL Server 2008.

apt-get install libgnutls-dev 
cd /usr/local/src
wget ftp://ftp.ibiblio.org/pub/Linux/ALPHA/freetds/current/freetds-current.tgz
tar xvzf freetds-current.tgz
cd freetds-0.83.dev*
./configure --prefix=/usr/local/freetds --with-tdsver=8.0 --enable-msdblib --enable-dbmfix --with-gnu-ld --with-gnutls
make -j3
make install
apt-get install libct4 libsybdb5 freetds-common
echo "libct4 hold" | dpkg --set-selections
echo "libsybdb5 hold" | dpkg --set-selections
echo "freetds-common hold" | dpkg --set-selections
rm /usr/lib/lib{ct,sybdb}*
ln -s /usr/local/freetds/lib/libct.so.4.0.0 /usr/lib/libct.so
ln -s /usr/local/freetds/lib/libct.so.4.0.0 /usr/lib/libct.so.4
ln -s /usr/local/freetds/lib/libct.so.4.0.0 /usr/lib/libct.so.4.0.0
ln -s /usr/local/freetds/lib/libsybdb.so.5.0.0 /usr/lib/libsybdb.so
ln -s /usr/local/freetds/lib/libsybdb.so.5.0.0 /usr/lib/libsybdb.so.5
ln -s /usr/local/freetds/lib/libsybdb.so.5.0.0 /usr/lib/libsybdb.so.5.0.0
ln -s /usr/local/freetds/include /usr/local/include/freetds
ln -s /usr/local/freetds/include /usr/include/freetds

Make sure the Apache user (www-data) has the rights to read files in /usr/local/freetds

Compilation of php-mssql

This allows us to use the PHP driver with this new FreeTDS library. This might not be needed anymore on Debian squeeze, just install php5-sybase.

apt-get install build-essential dpkg-dev debhelper
apt-get build-dep php5
cd /usr/local/src
apt-get source php5
cd php5*
echo "mssql MSSQL" >> debian/modulelist
echo -e "Package: php5-mssql\nArchitecture: any\nDepends: \${shlibs:Depends}, \${misc:Depends}, \${php:Depends}, php5-common (= \${Source-Version})\nDescription: MSSQL module for php5\n This package provides a module for MSSQL using FreeTDS.\n .\n PHP5 is an HTML-embedded scripting language. Much of its syntax is borrowed\n from C, Java and Perl with a couple of unique PHP-specific features thrown\n in. The goal of the language is to allow web developers to write\n dynamically generated pages quickly.\n" >> debian/control
dpkg-buildpackage -j2
dpkg -i ../php5-sybase*.deb
  • Put the relevant config options in /usr/local/freetds/etc/freetds.conf
  • Make sure the Apache user (www-data) can read this file