'MSSQL'에 해당되는 글 1건

  1. 2008.01.30 php 컴파일에 mssql을 포함시키자 2

php 컴파일에 mssql을 포함시키자

|

1. 컴파일

php에서 mssql을 사용하기 위해서는 FreeTDS 를 설치해 주어야 한다.

   사이트는 : http://www.freetds.org  이며
   다운은 : http://ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable.tgz 에서 받을수 있다.

   적당한 디렉토리에 풀자.

   #tar xvfz freetds-stable.tgz

   컴파일 해준다.

   #./configure --prefix=/usr --with-tdsver=8.0 --disable-odbc --disable-debug --enable-dbmfix --enable-msdblib
   #make
   #make install

   위 설정은 페도라/CentOS 기준이다. 사용자 별도의 디렉토리에 설치하고 싶다면 --prefix=디렉토리... 를
   변경하자.  --prefix=/usr/local/freeTDS  이정도 해주면 되겠다.

   그후 php 컴파일시 --with-mssql 만을 추가해주면 되겠다.
   사용자 별도의 디렉토리를 지정하였다면 저기 위에 지정해준 디렉토리를 입력한다. --with-mssql=디렉토리
   즉, freeTDS 컴파일시 등록한 prefix 내용을 입력하면 되겠다.

php 컴파일 후, 아파치 재시동하고 phpinfo()에서 mssql 이 나타나는것을 확인한후 사용하면 된다.

2. RPM 설치
마찬가지로 위의 사이트에 가면 찾을수 있다.
http://ibiblio.org/pub/Linux/ALPHA/freetds/stable/redhat/RPMS/  로 접속하면 바로 바로 받을수 있다.

freetds-0.62.1-1.i586.rpm 만 받아도 되고, 필요하다면 freetds-devel-0.62.1-1.i586.rpm 도 받아서

#rpm -ivh freetds-0.62.1-1.i586.rpm
#rpm -ivh freetds-devel-0.62.1-1.i586.rpm

아파치 재시동후 phpinfo()에서 mssql 나타나는것을 확인한후 사용하면 된다.

3. 환경설정
freetds 설치 디렉노리 밑의 freetds.conf 파일을 편집한다. 붉게 표시된 부분을 자신에 맞게 고쳐쓰자.

[global]
 # TDS protocol version
 tds version = 4.2
; initial block size = 512
 # uses some fixes required for some bugged MSSQL 7.0 server that
 # return invalid data to big endian clients
 # NOTE TDS version 7.0 or 8.0 should be used instead
; swap broken dates = no
; swap broken money = no
 # Whether to write a TDSDUMP file for diagnostic purposes
 # (setting this to /tmp is insecure on a multi-user system)
; dump file = /tmp/freetds.log
; debug flags = 0xffff
 # Command and connection timeouts
; timeout = 10
; connect timeout = 10
 
 # If you get out of memory errors, it may mean that your client
 # is trying to allocate a huge buffer for a TEXT field. 
 # (Microsoft servers sometimes pretend TEXT columns are
 # 4 GB wide!)   If you have this problem, try setting
 # 'text size' to a more reasonable limit
 text size = 64512
 client charset = EUC-KR
# This is a Sybase hosted database server, if you are directly on the
# net you can use it to test.
;[JDBC]
 ;host = 192.138.151.39
 ;port = 4444
 ;tds version = 5.0
# The same server, using TDS 4.2.  Used in configuration examples for the
# pool server, since the pool server supports only TDS 4.2.
;[JDBC_42]
; host = 192.138.151.39
; port = 4444
; tds version = 4.2
# The client connecting to the pool server will use this to find its
# listening socket.  This entry assumes that the client is on the same
# system as the pool server.
;[mypool]
; host = 127.0.0.1
; port = 5000
; tds version = 4.2
# A typical Microsoft SQL Server 7.0 configuration
;[MyServer70]
; host = ntmachine.domain.com
; port = 1433
; tds version = 7.0
# A typical Microsoft SQL Server 2000 configuration
[MyServer2k]
host = 111.222.111.222
port = 1433
tds version = 8.0
 
# A typical Microsoft SQL Server 6.x configuration
;[MyServer65]
; host = ntmachine.domain.com
; port = 1433
; tds version = 4.2

4. 사용예

$MS_host      = "MyServer2k";  //위의 freetds.conf 에서 지정한내용
$MS_dbname = "DB 명";
$MS_user      = "DB 아이디";
$MS_pass     = "DB 비밀번호";

$MS_conn = mssql_connect($MS_host,$MS_user,$MS_pass)) ;
mssql_select($MS_dbname, $MS_conn);
......

- 끝 -


And
prev | 1 | next