php/PDO access to MS SQL Server from Ubuntu 16.04 LTS Server

The replacement of a Ubuntu 10.04 LTS server with one running Ubuntu 16.04 LTS necessitated moving from the php mssql_* functions to the PDO functions. This required the installation of the “dblib” PDO driver and FreeTDS. It took a fair bit of ferreting around to get it to work, so here’s a summary.

Installation of php 7.0 and php 5.6

See http://lornajane.net/posts/2016/php-7-0-and-5-6-on-ubuntu

Summary:

Installation of modules

Changing php versions

From php5.6 to php7.0:
Apache:

CLI:

from php7.0 to php5.6:
Apache:

CLI:

FreeTDS config

Example connection, retrieve SQL Server version, execute SELECT query, and display results

Leave a Reply