Installing MS SQL Server Client Library on Linux/Unix

Problem: Installing SQL Server client library on Debian/Ubuntu Linux.

If you want to install PHP on a Linux machine and want to use Sql Server as your database then you have to install FreeTDS library on your server machine so that you could make your PHP/Apache server machine talk to your SQL Server 2000 Database. Let's go through the installation steps.

I have used the instructions on Debian/Ubuntu server machines. Make sure you have GNU compilation tools and libraries.

In Debian/Ubuntu, try the following:

gcc -v
make -v

If you see the version numbers of the above two software that means gcc and make are installed on your computer. If you dont have these software installed then you have to first install them.

In Ubuntu, do the following

sudo apt-get install build-essential

This will install the necessary software on your computer. I'd recommend using wget FTP client to download the software on Linux/Unix machines.

wget http://ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable.tgz

The above command will download the software. Now, unzip and untar the downloaded gzipped tar file by executing the command below.

tar –xvzf freetds-stable.tgz

Enter the folder where you untarred the downloaded file.

cd freetds-0.64

Replace 0.64 with your version number. Configure and compile the software as follows (make sure you execute 'make install' command below as root):

./configure --prefix=/usr/local/freetds --enable-msdblib
make
# make install
cd ..

FreeTDS has been installed in the folder /usr/local/freetds. Now, if you want to install PHP then you have to configure PHP (while installing) using the switch as follows:

--with-mssql=/usr/local/freetds

I hope this will be a greate help for you. Please let me know if you want me to write on something else.

Did this tutorial help a little? How about buy me a cup of coffee?

Buy me a coffee at ko-fi.com

Please feel free to use the comments form below if you have any questions or need more explanation on anything. I do not guarantee a response.

IMPORTANT: You must thoroughy test any instructions on a production-like test environment first before trying anything on production systems. And, make sure it is tested for security, privacy, and safety. See our terms here.

Comments (write a comment):

Hi,
I've tried to install this library.
But how control that the library is good installed ?

Php was already installed, so I use this command before the "make":
"./configure --prefix=/usr/local/freetds --enable-msdblib --with-mssql=/usr/local/freetds"

But after a Apache restart, allways no connection. The mssql fonction returns a "could not find driver". And there is nothing more in the phpinfo(), no mention about the Freetds library.

Can you help me?

Thx. (and sorry for my english) Posted by: Jerem on Jun 14, 2012

leave a comment on tutorial leave a comment