Changes

From SME Server
Jump to navigationJump to search
3,559 bytes added ,  11:43, 18 June 2009
Created ODBC page
{{Languages}}
{{Warning box| Under construction, some content may be totally wrong and misleading.}}
===Description===
Adding support in SME Server for a universal connection to foreign datebase servers using Open Database Connectivity (ODBC).

===Used packages===
unixODBC.i386 - [http://www.unixODBC.org unixODBC official site]

unixODBC-devel.i386

php-odbc.i386 - a module for PHP applications that use ODBC databases.

freetds - a re-implementation of the Tabular Data Stream protocol made by Sybase and Microsoft. [http://www.freetds.org/ FreeTDS official site]

Optional: gcc

===Installation===
Install basic packages via server-manager:

unixODBC.i386

unixODBC-devel.i386

php-odbc.i386

====Alt 1: Install precompiled FreeTDS====
Install FreeTDS from Dag repository
yum --enablerepo=dag install freetds freetds-devel

signal-event post-upgrade; signal-event reboot

====Alt 2: Install FreeTDS from source====
wget http://ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-0.82.tar.gz

gzip -d freetds-0.82.tar.gz

tar -xvf freetds-0.82.tar

yum install gcc

cd freetds-0.82

./configure --sysconfdir=/etc --enable-msdblib --with-tdsver=8.0

make

make install

make clean

signal-event post-upgrade; signal-event reboot

{{Warning box|msg=Leaving gcc on a production server is considered a security risk, if you do not really need it you should not install it, if you need it you should seriously consider uninstalling gcc when you no longer need it. Removing gcc can be done using the following command:
yum remove gcc}}

====Test with tsql====
Check settings:

tsql -C
Should output someting similar to this:
Compile-time settings (established with the "configure" script)
Version: freetds v0.82
freetds.conf directory: /usr/local/etc
MS db-lib source compatibility: no
Sybase binary compatibility: no
Thread safety: yes
iconv library: yes
TDS version: 8.0
iODBC: no
unixodbc: yes

Test connection to a foreign database, overriding settings in freetds.conf:

tsql -S 192.168.0.112 -U testuser -P testpass

===Configuration===
====freetds.conf====
mkdir -p /etc/e-smith/templates-custom/etc/freetds.conf
pico /etc/e-smith/templates-custom/etc/freetds.conf/10xp3c
Add your foreign database server (modify to suit your conditions):
# SQL Server on Win XP machine
[xp3c]
host = 192.168.0.112
port = 1433
tds version = 8.0
instance = db_kalle

expand-template /etc/freetds.conf

====odbcinst.ini====
mkdir -p /etc/e-smith/templates-custom/etc/odbcinst.ini
pico /etc/e-smith/templates-custom/etc/odbcinst.ini/20sqlserver
Add driver path (modify to suit your conditions):
[FreeTDS]
Description = Ms SQL Server access with FreeTDS driver
Driver = /usr/lib/libtdsodbc.so

expand-template /etc/odbcinst.ini

====odbc.ini====
mkdir -p /etc/e-smith/templates-custom/etc/odbc.ini
pico /etc/e-smith/templates-custom/etc/odbc.ini/20sqlserver
Add text (modify to suit your conditions):
[sqlserver]
Driver = FreeTDS
Description = Connection to DB_KALLE on server xp3c
Trace = No
Server = 192.168.0.112
Database = db_kalle
Port = 1433
TDS_Version = 8.0

expand-template /etc/odbc.ini

====Check PHP configuration====
phpinfo(), section Configure Command, outputs: --with-unixODBC=shared,/usr
There should also be a section "odbc".

PHP function odbc_connect should now work.

=== Additional information ===
Current forum discussion at http://forums.contribs.org/index.php?topic=44185.0

[http://se2.php.net/manual/en/book.uodbc.php php.net ODBC]

----
[[Category:Howto]]
206

edits

Navigation menu