tohokuaikiのチラシの裏

技術的ネタとか。

Oracleドライバを入れる

CentOS5で。

ExpressEdition(Oracle Database 10g Release 2 (10.2.0.1))は、OracleのサイトでRPMで提供されているのでサクッとrpm -ivhでインストール。

PHPで使うので、Peclのoci8ドライバを入れる。

その前に、
http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxsoft.html
から

Instant Client Package - Basic: All files required to run OCI, OCCI, and JDBC-OCI applications
oracle-instantclient11.1-basic-11.1.0.7.0-1.i386.rpm (43,968,859 bytes) (cksum - 3856494421)


Instant Client Package - SDK: Additional header files and an example makefile for developing Oracle applications with Instant Client
oracle-instantclient11.1-devel-11.1.0.7.0-1.i386.rpm (578,817 bytes) (cksum - 1927132852)

をダウンロードしてきて入れておく。

で、
#pecl install oci8
でインストール。

途中で、

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] :

って聞かれるけど、そのままリターン。あるいは、
instantclient,/usr/lib/oracle/11.1/client/lib
を入れるか。


Peclでインストールの最後に
You should add "extension=oci8.so" to php.ini
って言われるので、/etc/php.iniに記述してApache再起動。


$con = oci_connect('sys', '*********', 'localhost:1521/xe');
var_dump($con);

ってやるとダメ。ちゃんと接続用の一般のOracleユーザーのアカウントを作ること。