freetds install
1. 최신 버전 설치
1 2 3 4 5 6 7 8 9 10 11 |
[root@localhost ~]# wget ftp://ftp.freetds.org/pub/freetds/stable/freetds-patched.tar.gz [root@localhost ~]# tar xvfz freetds-patched.tar.gz [root@localhost ~]# cd freetds-0.95.74/ [root@xinet freetds-0.95.74]# ./configure -prefix=/usr/local/freetds --with-tdsver=8.0 --disable-odbc --disable-debug --enable-dbmfix --enable-msdblib [root@xinet freetds-0.95.74]# make [root@xinet freetds-0.95.74]# make install |
2. PHP 설치 디렉토리를 이동한다 / 만약 처음 설치한 파일이 없다면 해당 버전 PHP 압축을 풀고 진행
1 2 3 4 5 6 7 8 9 10 11 12 13 |
[root@xinet ~]# cd php-5.4.45/ext/mssql/ [root@xinet mssql]# /usr/local/php/bin/phpize [root@xinet mssql]# ./configure --with-php-config=/usr/local/php/bin/php-config --with-mssql=/usr/local/freetds [root@xinet mssql]# make [root@xinet mssql]# make install Installing shared extensions: /usr/lib64/extensions/no-debug-non-zts-20100525/ [root@xinet mssql]# ll /usr/lib64/extensions/no-debug-non-zts-20100525/mssql.so -rwxr-xr-x 1 root root 138247 2015-12-10 16:39 <strong><span style="color: #00ff00;">/usr/lib64/extensions/no-debug-non-zts-20100525/mssql.so</span></strong> |
3. PHP.INI 파일에 mssql.so 파일 등록
1 2 3 4 5 |
[root@xinet mssql]# vi /usr/local/apache/conf/php.ini extension_dir = "/usr/lib64/extensions/no-debug-non-zts-20100525/" extension = "mssql.so" |
4. phpinfo 화면에서 ms-sql 이 나오는지 확인
5. freetds.conf 파일에 연결한 ms-sql 서버 정보를 입력한다.
1 2 3 4 5 6 |
[root@xinet mssql]# vi /usr/local/freetds/etc/freetds.conf [2012.xinet.kr] host = 192.168.10.100 port = 1433 tds version = 8.0 |
6. 웹상에 소스 파일을 하나 만들어서 ms-sql 파일의 정보를 불러 들이는지 확인해보자 (SQL의 ZIP CODE 상위 100개 출력)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
[root@xinet mssql]# vi /free/home/xinet/html/mssql.php <?php putenv("FREETDSCONF=/usr/local/freetds/etc/freetds.conf"); putenv("TDSVER=70"); // tds 버전을 여기다 적어두 된다 $hostname = "2012.xinet.kr"; // freetds.conf 에서 적어준걸로.. $username = "testuser"; $password = "testpass"; $dbname = "testuser"; $connection = mssql_connect($hostname,$username,$password); mssql_select_db($dbname); echo("<table border=1>"); $query = "select top 100 * from T_ZIPCODE" ; $query_result = mssql_query($query) ; $number_rows = mssql_num_rows($query_result) ; $number_fields = mssql_num_fields($query_result) ; for ($row_number=0; $row_number<=$number_rows-1; $row_number++) { print "<tr>"; for ($field_number=0; $field_number<=$number_fields-1; $field_number++) { print "<td>" . mssql_result($query_result, $row_number, $field_number) . "</td>" ; } print "</tr>"; } print "</table>"; mssql_close($connection); ?> |
7. 웹상에서 확인하면 다음과 같다
아래 내용은 기존에 작성했던 내용이다. 별거 없다 상위만 내용 볼것
wget ftp://ftp.freetds.org/pub/freetds/stable/freetds-stable.tgz
tar xvfz freetds-stable.tgz
cd freetds-0.91/
./configure -prefix=/usr/local/freetds –with-tdsver=8.0 –disable-odbc –disable-debug –enable-dbmfix –enable-msdblib
make
make install
cp include/tds.h /usr/local/freetds/include/
cp src/tds/.libs/libtds.a /usr/local/freetds/lib/
cd php-5.2.5/
cd ext/mssql
/usr/local/php/bin/phpize
./configure –with-php-config=/usr/local/php/bin/php-config –with-mssql=/usr/local/freetds
make
make install
ll /usr/local/php/lib/php/extensions/no-debug-zts-20060613/
vi /usr/local/Zend/etc/php.ini
extension_dir = /usr/local/php/lib/php/extensions/no-debug-zts-20060613/
extension = “mssql.so”
vi /usr/local/freetds/etc/freetds.conf
[xinet_mssql]
host = 192.168.10.1
port = 1433
tds version = 8.0
php 파일은 지난 내용에서 확인
http://xinet.kr/tc/20