字體:  

php-oci8 on centos5 ...解決連結Oracle 讀取中文變亂碼問題

adj 發表於: 2008-4-28 14:42 來源: ADJ網路控股集團


環境: CentOS5 i386

QUOTE:

# wget http://ftp.freshrpms.net/pub/fre ... 0.2.0.3-1.nosrc.rpm # rpm -ivh oracle-instantclient-10.2.0.3-1.nosrc.rpm # wget ftp://fr.rpmfind.net/linux/fedor ... 3-3.2.3-63.i386.rpm # rpm -ivh compat-libstdc++-33-3.2.3-63.i386.rpm
取得 http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxsoft.html 底下的 instantclient-basic-linux32-10.2.0.3-20061115.zip instantclient-jdbc-linux32-10.2.0.3-20061115.zip instantclient-odbc-linux32-10.2.0.3-20061115.zip instantclient-sdk-linux32-10.2.0.3-20061115.zip instantclient-sqlplus-linux32-10.2.0.3-20061115.zip 將上述檔案放到 /usr/src/redhat/SOURCES 然後開始編繹了

QUOTE:

# cd /usr/src/redhat # rpmbuild -ba SPECS/oracle-instantclient.spec
接下來把編出來的東西都裝一裝。unixODBC 一般人不會裝到, 所以列在下面免得漏掉

QUOTE:

# yum install unixODBC.i386 # cd /usr/src/redhat/RPMS # for i in *.rpm; do rpm -hiv ${i}; done

QUOTE:

# wget http://ftp.freshrpms.net/pub/fre ... .1.6-1.el5.i386.rpm # rpm -ivh http://ftp.freshrpms.net/pub/fre ... .1.6-1.el5.i386.rpm # ldconfig (refresh cache. 好像不用? 管它, 有拜有保佑)
接下來就是重啟 apache # service httpd restart 開 phpinfo 去看, 應當可以看到 oci8 在裡面了。 此時用 php 連線至Oracle 的資料...show出來的可能會是亂碼...那你可以編輯 /etc/init.d/httpd 加入一行

QUOTE:

export NLS_LANG="TRADITIONAL CHINESE_TAIWAN.zht16big5"
然後 Apache重啟...這時再試試看...抓到的資料應該就會是正常的了... 參考資料: http://www.ihao.org/dz5/thread-3482-1-1.html http://blog.bsdchat.com/2007/08/php-oci8-on-centos5.html