We will create a MS SQL Server connection without the need to compile PHP packages, we will use the FreeTDS which is available in apt repository.
Note: To connect to SQL Server 2008 use version 8.0 of the TDS.
For more details see the following article: http://www.freetds.org/userguide/logging.htm
Step 1: Installing FreeTDS.
On your Linux shell, type:
"sudo apt-get install php5-odbc tdsodbc unixodbc freetds-dev php5-sybase"
Note: all operations as root
Step 2: Installing the packages, we will create the file templates DNS
In Linux shell:
Step 3: Add the following content to the file
MSSQL Description = FreeTDS Driver for Linux Debian 5 - "Lenny"
Driver = /usr/lib/odbc/libtdsodbc.so
Setup = /usr/lib/odbc/libtdsS.so "
Step 4: We will now register the ODBC
Step 5: We will register the base that will be accessed by ODBC. Remembering that each base requires a different ODBC, so if you have more than one, keep repeating the commands.
Create the file: "vim/etc/freetds/tds.dsn.template"
Description = ODBC Test - FreeTDS
Driver = TDS
Trace = No
Database = EIRAS
Server = 192.168.100.50
Port = 1433 "
NOTE: Remember to change the name "DSN" above. This name will be used in the application to identify the ODBC. Generally it has the same name as the database. (Database)
Step 6: Let the record ODBs and DSNs:
odbcinst-i-s-f /etc/freetds/tds.dsn.template "
| ODBC are registered to the users who create them (in our case, the root), but in this case, we will leave the record for use of the system, it will be used by apache. So we will copy the contents to the file global access.
"cat /root/.odbc.ini >>/etc/ odbc.ini"
Step 7: Let's make apache recognize the ODBC driver
Add the line:
extension = odbc.so "
Step 8: Restart apache
Step 9: Now your ODBC should work via PHP.
To test, type the command into the shell:
"Isql-v DSN sa password"