I recently had the pleasure(!) of trying to get PHP on Debian working correctly with a Microsoft SQL server so that the data could be migrated from a Mssql instance into a Mysql one.
Previous to this attempt, the developers were using a Windows machine as a ‘broker’ between the two database. This setup was much too slow for importing and exporting large amounts of data, Â so we decided to cut out the middle man (the Windows machine) and do all the processing on a single server.
First I needed to install a few prerequisite packages:
apt-get install unixodbc-dev
apt-get install libmysqlclient15-dev
Next we need to download and uncompress the FreeTDS source code:
Next we use configure and install FreeTDS with the following options:
./configure --enable-msdblib --prefix=/usr/local/freetds --with-tdsver=7.0 --with-unixodbc=/usr
Next we need to download and uncompress the PHP source code:
Next we use configure and install PHP with the following options:
./configure --with-mssql=/usr/local/freetds --with-mysql --with-mysqli
Lastly we will need to create and install the mssql module for PHP:
Now you should be able to connect to any Microsoft SQL (and Mysql) server from PHP using the functions found here.