因為工作的需要~需要透過php去連接Oracle資料庫
php除了連接mysql之外~也要連接Oracle資料庫
因為~公司主要的資料庫都是Oracle10g
1.鼎新tiptop GP5
2.MES
所以想利用php去oracle裡抓資料出來用~
我的php環境是Base on php5之上~
使用的OS~是Centos 5.0版
記憶體512MB ASUS 1U Server
Oracle原廠網站上提供了兩隻rpm
分別是
oracle-instantclient-basic-10.2.0.4-1.i386.rpm
oracle-instantclient-devel-10.2.0.4-1.i386.rpm
但是這兩隻rpm的處理方式~
在官方文件中說的不清楚~
而且~如果要讓php在apache中被支援~
這整個動作變的很麻煩~
要重新編過apache(httpd)
所以最簡單的處理方式就是動態載入
1.yum install php-devel php-pear
安裝這兩個必要的package 當然 也可以使用apt來安裝~
因為我的CentOS沒有裝apt替件,我就用yum來裝 2.mkdir -p /opt/oracle;cd /opt/oracle
建立暫存資料匣並且進入
3.unzip ~/oracle-instantclient-basic-10.2.0.4-1.i386.zip
4.unzip ~/oracle-instantclient-devel-10.2.0.4-1.i386.zip
這兩個解壓縮的步驟所需的zip檔要放在自己的家目錄中 5.mv instantclient_10_2 instantclient;cd /opt/oracle/instantclient
目錄更名,並且進入
6.ln -s libclntsh.so.10.1 libclntsh.so 7.ln -s libocci.so.10.1 libocci.so
建立連結 8.pecl install oci8
產生外掛模組檔螢幕出現: Please provide the path to ORACLE_HOME dir. Use ‘instantclient,/path/to/instant/client/lib’ if you’re compiling against Oracle Instant Client [autodetect] : 請輸入: shared,instantclient,/opt/oracle/instantclient 到此完成2/3
9.vi /etc/php.ini 加入 extension=oci8.so 10.service httpd restart
大功告成
隨機文章
- 受保護的內容: 中小企業的生存之道~晶玻實業~雷射水晶 (2008-01-01)
- 18歲少女 柔柔遺愛 器捐救30人 (2007-10-31)
- 匯入MySQL資料需要耐心 (2014-12-01)
- 免費沒好貨~免費DNS~小心你不能順利操作~ (2009-03-20)
- TEAMVIEWER:無法建立連線。連線會在逾時之後遭封鎖。您的授權限制了夥伴的工作階段持續時間最大值 (2017-02-11)