Connect phpGrid to MS SQL Server in Linux

When connecting phpGrid to SQL Server in Linux, it's common to receive a warning similar to the following:

Warning: odbc_connect() [function.odbc-connect]: SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQLConnect.

To access MSSQL from *nix, install FreeTDS and unixODBC, 

sudo apt-get unixodbc unixodbc-dev freetds-dev tdsodbc
then configurate freetds.conf, odbc.ini and odbcinst.ini 

--- /etc/odbc.ini ---
[TS]
Description = "test"
Driver = FreeTDS
Server = SERVER_NAME
Port = 1433
Database = DBNAME

--- /etc/odbcinst.ini ---
[FreeTDS]
Description = FreeTDS
Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so

--- /etc/freetds/freetds.conf ---
[TS]
host = SERVER_NAME
port = 1433
tds version = 7.0
client charset = UTF-8

Finally, add setting to the server environment in conf.php.

// conf.php putenv("ODBCINSTINI=/usr/local/Cellar/unixodbc/2.3.1/etc/odbcinst.ini"); putenv("ODBCINI=/usr/local/Cellar/unixodbc/2.3.1/etc/odbc.ini");

Feedback and Knowledge Base