2012/09/13

OCI for PHP 安裝 in CENTOS6 x86_64


ORACLE 的 php 支援說明
http://www.oracle.com/technetwork/topics/php/downloads/index.html

需要先安裝 Oracle Database Instant Client
http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html

下載,他會依據作業系統給你載點,並且要求你登入 oracle (免費註冊)
http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html
請抓取  basic 及 devel 這兩個檔案

[root@power app]# rpm -ivh oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm 
[root@power app]# rpm -ivh oracle-instantclient11.2-devel-11.2.0.3.0-1.x86_64.rpm 

# 安裝 php-devel 、php-pear 以及 gcc 編譯套件
[root@power app]# yum install php-devel php-pear gcc

# 使用 pecl 直接安裝 http://pecl.php.net/package/oci8 ,這是一個 PHP 的元件,會需要編譯所以需要上面兩個 oracle instat client 套件的資料
[root@power app]# pecl install oci8
WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
downloading oci8-2.0.6.tgz ...
Starting to download oci8-2.0.6.tgz (189,668 bytes)
.....................................done: 189,668 bytes
11 source files, building
running: phpize
Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626
Please provide the path to the ORACLE_HOME directory. Use 'instantclient,/path/to/instant/client/lib' if you're compiling with Oracle Instant Client [autodetect] :  <-- enter="" font="">

省略 n 行....

Build process completed successfully
Installing '/usr/lib64/php/modules/oci8.so'
install ok: channel://pecl.php.net/oci8-2.0.6
configuration option "php_ini" is not set to php.ini location
You should add "extension=oci8.so" to php.ini



# 編譯完成後請將 extension=oci8.so 這一行加入 /etc/php.ini
[root@power app]# vim /etc/php.ini
extension=oci8.so


# 重新啟動 httpd

[root@power app]# /etc/init.d/httpd restart


# 觀看 phpinfo(); 程式的內容,應該會看到 oci8 的模組已經被載入內容應該如下列

oci8

OCI8 Supportenabled
Version1.4.7
Revision$Revision: 321634 $
Active Persistent Connections0
Active Connections0
Oracle Run-time Client Library Version11.2.0.3.0
Oracle Instant Client Version11.2
Temporary Lob supportenabled
Collections supportenabled

DirectiveLocal ValueMaster Value
oci8.connection_classno valueno value
oci8.default_prefetch100100
oci8.eventsOffOff
oci8.max_persistent-1-1
oci8.old_oci_close_semanticsOffOff
oci8.persistent_timeout-1-1
oci8.ping_interval6060
oci8.privileged_connectOffOff
oci8.statement_cache_size2020



# 那就寫程式去巴!!! 請參考 php oci 的說明
http://www.php.net/manual/zh/function.oci-connect.php


張貼留言

like