rianto isaac's Weblog

rianto utomo isaac sahala utomo

php-mssql, linux apache php to mssql server

leave a comment »

ikutin link http://www.easysoft.com/developer/languages/php/sql_server_unix_tutorial.html lengkap banget..

ini juga http://www.linuxjournal.com/article/6636

ada lagi http://nyemplunglinux.blogspot.com/2009/05/php-konek-ms-sql-server-kenapa-tidak.html

finishing pake ini: http://www.unixodbc.org/doc/FreeTDS.html

tokcer sih pake yg ini: http://www.kcaran.com/entries/technology/linux/linuxodbc.html

Configuration

  1. Add SQL Server hosts to the FreeTDS configuration file:
    /etc/freetds/freetds.conf (Ubuntu/Debian)
    /usr/local/etc/freetds.conf (Red hat)

    [TDSproduction]
            host = 10.28.78.52
            port = 1433
            tds version = 7.0
  2. Confirm the new drivers are in the driver config file:
    /etc/odbcinst.ini(Ubuntu/Debian and Red Hat)

    [FreeTDS]
    Description     = MS SQL driver
    Driver          = /usr/local/lib/libtdsodbc.so
    FileUsage       = 2
    
    [ODBC]
    Trace           = No       ;(=Yes if tracing using unixODBC)
    
    [iSeries Access ODBC Driver]
    Description     = iSeries Access for Linux ODBC Driver
    Driver          = /opt/ibm/iSeriesODBC/lib/libcwbodbc.so
    Setup           = /opt/ibm/iSeriesODBC/lib/libcwbodbc.so
    Threading       = 2
    FileUsage       = 1
  3. Add servers to the server file:
    /etc/odbc.ini (Ubuntu/Debian and Red Hat)
    /usr/local/etc/odbc.ini(Red Hat).

    [Production]
    Driver                  = FreeTDS
    Description             = Production MS SQL Database
    Servername              = TDSproduction
    Database                = AVC
    UID                     = content1_badsg-1
    
    [AS400]
    Driver                  = iSeries Access ODBC Driver
    Description             = Production AS/400 Database
    Servername              = AS400.APPN.SNA.IBM.COM
    System                  = AS400.APPN.SNA.IBM.COM
    DefaultLibraries        = TESTMS
    UID                     = webodbc

Test the Connections

  1. Verify unixODBC setup using odbcinst:
    # odbcinst -q -d
    	[FreeTDS]
    	[iSeries Access ODBC Driver]
    
    # odbcinst -q -s
    	[Production]
    	[AS400]
  2. Test connection to FreeTDS servers using tsql.
    Note: make sure you use the server name, not the ODBC DSN, for the -S argument. See man tsqlfor more details.

    # tsql -STDSproduction -Usa
  3. Test connections through unixODBC:
    # isql AS400 username PASSWORD
  4. Debugging tools for connecting to AS400:
    # /opt/ibm/iSeriesODBC/bin/cwbping as400.appn.sna.ibm.com

kelengkapan berikutnya ada disini http://rendyriskianto.blogspot.com/2010/11/setting-dns-di-suse-111.html

jangan lupa juga, buat ngecek pake isql, tsql, osql

klo pusing baca lagi http://www.freetds.org/userguide/odbcdiagnose.htm

di PHP
<?php $conn=odbc_connect($data_source,$user,$password); ?>

cek errornya pake script
$con = odbc_connect(“”, “”, “”) or die(“Error :”.odbc_errormsg());
$q = “select * from sysfiles”;
$r = odbc_exec($con,$q) or die(“Error :”.odbc_errormsg());

untuk mssql_connect perlu tambahan:
ftp://rpmfind.net/linux/Mandriva/devel/cooker/i586/media/main/release/libfreetds0-0.91-1-mdv2012.0.i586.rpm
ftp://ftp.pbone.net/mirror/archive.fedoraproject.org/fedora/linux/releases/9/Fedora/x86_64/os/Packages/readline-5.2-13.fc9.x86_64.rpm
ftp://rpmfind.net/linux/fedora/releases/16/Everything/x86_64/os/Packages/ncurses-libs-5.9-2.20110716.fc16.i686.rpm
ftp://rpmfind.net/linux/fedora/releases/16/Everything/x86_64/os/Packages/ncurses-base-5.9-2.20110716.fc16.x86_64.rpm

intinya sih:

vi /usr/local/etc/freetds.conf
ditambahkan baris:
[to3f]
host = 10.0.0.3
port = 1433
tds version = 7.0

[to9f]
host = 10.0.0.9
port = 1433
tds version = 7.0

vi /etc/odbcinst.ini
ditambahkan baris:
[to3f]
Description = FreeTDS driver
Driver = /usr/local/lib/libtdsodbc.so
Setup = /usr/local/lib/libtdsodbc.so
Trace = Yes
TraceFile = /tmp/freetds.log
FileUsage = 1

[to9f]
Description = FreeTDS driver
Driver = /usr/local/lib/libtdsodbc.so
Setup = /usr/local/lib/libtdsodbc.so
Trace = Yes
TraceFile = /tmp/freetds.log
FileUsage = 1

vi /etc/odbc.ini
ditambahkan baris:
[to3f]
Driver = to3f
Description = MS SQL Test
Trace = Yes
TraceFile = /tmp/mstest.log
Servername = 10.0.0.3
Database = master
Port = 1433

[to9f]
Driver = to9f
Description = MS SQL Test 9
Trace = Yes
TraceFile = /tmp/mstest9.log
Servername = 10.0.0.9
Database = master
Port = 1433

vi /etc/named.conf
ditambahkan baris:
zone “sqlail.ail” in {
type master;
file “sqlail”;
};

zone “sql9.ail” in {
type master;
file “sql9”;
};

copy dari /var/lib/named/127.0.0.zone
ditambahkan baris:
ns              IN A            10.0.0.9
@               IN A            10.0.0.9
simpan sebagai:
vi /var/lib/named/sqlail
vi /var/lib/named/sql9

Written by isaaconi

November 16, 2011 pada 1:09 pm

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: