adj 2008-4-28 14:42
php-oci8 on centos5 ...解決連結Oracle 讀取中文變亂碼問題
環境: CentOS5 i386
[quote]# wget [url=http://ftp.freshrpms.net/pub/freshrpms/redhat/testing/EL5/oracle/SRPMS/oracle-instantclient-10.2.0.3-1.nosrc.rpm]http://ftp.freshrpms.net/pub/fre ... 0.2.0.3-1.nosrc.rpm[/url]
# rpm -ivh oracle-instantclient-10.2.0.3-1.nosrc.rpm
# wget [url=ftp://fr.rpmfind.net/linux/fedora/development/i386/os/Packages/compat-libstdc++-33-3.2.3-63.i386.rpm]ftp://fr.rpmfind.net/linux/fedor ... 3-3.2.3-63.i386.rpm[/url]
# rpm -ivh compat-libstdc++-33-3.2.3-63.i386.rpm[/quote]
取得 [url=http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxsoft.html]http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxsoft.html[/url] 底下的
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 [/quote]
接下來把編出來的東西都裝一裝。unixODBC 一般人不會裝到, 所以列在下面免得漏掉
[quote]# yum install unixODBC.i386
# cd /usr/src/redhat/RPMS
# for i in *.rpm; do rpm -hiv ${i}; done[/quote]
[quote]# wget [url=http://ftp.freshrpms.net/pub/freshrpms/redhat/testing/EL5/oracle/i386/php-oci8-5.1.6-1.el5.i386.rpm]http://ftp.freshrpms.net/pub/fre ... .1.6-1.el5.i386.rpm[/url]
# rpm -ivh [url=http://ftp.freshrpms.net/pub/freshrpms/redhat/testing/EL5/oracle/i386/php-oci8-5.1.6-1.el5.i386.rpm]http://ftp.freshrpms.net/pub/fre ... .1.6-1.el5.i386.rpm[/url]
# ldconfig
(refresh cache. 好像不用? 管它, 有拜有保佑)[/quote]
接下來就是重啟 apache
# service httpd restart
開 phpinfo 去看, 應當可以看到 oci8 在裡面了。
此時用 php 連線至Oracle 的資料...show出來的可能會是亂碼...那你可以編輯 [color=red]/etc/init.d/httpd[/color]
加入一行
[quote]export NLS_LANG="TRADITIONAL CHINESE_TAIWAN.zht16big5"[/quote]
然後 Apache重啟...這時再試試看...抓到的資料應該就會是正常的了...
參考資料:
[url=http://www.ihao.org/dz5/thread-3482-1-1.html]http://www.ihao.org/dz5/thread-3482-1-1.html[/url]
[url=http://blog.bsdchat.com/2007/08/php-oci8-on-centos5.html]http://blog.bsdchat.com/2007/08/php-oci8-on-centos5.html[/url]