SolarisでOracleクライアントをインストールしてPHPから使う
phpからOracleDBに接続したいという要望があり、phpをOracleクライアントが見えるように再構築。まずOracleクライアントをインストールします。
Oracleクライアントインストール
Instant Client Package-Basicをダウンロード。ダウンロードしたinstantclient-basic-solaris32-10.2.0.2-20060303.zipを解凍して適当なディレクトリにぶち込みます。LD_LIBRARY_PATHで見えてないといけないらしいので、/usr/local/libへ突っ込みました。
$ unzip instantclient-basic-solaris32-10.2.0.2-20060303.zip $ cd instantclient_10_2 $ ls classes12.jar libnnz10.so libociei.so ojdbc14.jar libclntsh.so.10.1 libocci.so.10.1 libocijdbc10.so # cp * /usr/local/lib
phpの再ビルド
configureに--with-oci8をつけるといいようです。上記でクライアント(ライブラリ)をコピーした先を指定します。
$ ./configure (中略) --with-oci8=/usr/local $ /usr/local/bin/make In file included from /export/home2/hoge/php/php-4.4.1/ext/oci8/oci8.c:69: /export/home2/hoge/php/php-4.4.1/ext/oci8/php_oci8.h:52:17: error: oci.h: No such file or directory
ファイルがないって言っています。oci.hというファイル確かにありません。入れた覚えもないし。このファイル、接続する先のOracleが入っているサーバにあります。rdbms/demoの下。これを/usr/local/includeとか適当に見えるところに移します。移したら再度make。
$ /usr/local/bin/make In file included from /export/home2/hoge/php/php-4.4.1/ext/oci8/php_oci8.h:52, from /export/home2/hoge/php/php-4.4.1/ext/oci8/oci8.c:69: /usr/include/oci.h:350:23: error: oratypes.h: No such file or directory /usr/include/oci.h:354:20: error: ocidfn.h: No such file or directory In file included from /export/home2/hoge/php/php-4.4.1/ext/oci8/php_oci8.h:52, from /export/home2/hoge/php/php-4.4.1/ext/oci8/oci8.c:69:
こんどは、ortypes.hとocidfn.hがないって言っています。いっぺんに言ってくれないかな。これも上記oci.hと同じところにあるので、移してきます。そして再度make。
$ /usr/local/bin/make In file included from /export/home2/hoge/php/php-4.4.1/ext/oci8/php_oci8.h:52, from /export/home2/hoge/php/php-4.4.1/ext/oci8/oci8.c:69: /usr/include/oci.h:2147:18: error: oci1.h: No such file or directory /usr/include/oci.h:2151:17: error: oro.h: No such file or directory /usr/include/oci.h:2155:17: error: ori.h: No such file or directory /usr/include/oci.h:2159:17: error: orl.h: No such file or directory /usr/include/oci.h:2163:17: error: ort.h: No such file or directory /usr/include/oci.h:2167:21: error: ociextp.h: No such file or directory /usr/include/oci.h:2171:20: error: ociapr.h: No such file or directory /usr/include/oci.h:2172:19: error: ociap.h: No such file or directory /usr/include/oci.h:2179:80: error: oci8dp.h: No such file or directory /usr/include/oci.h:2187:80: error: ocixad.h: No such file or directory In file included from /export/home2/hoge/php/php-4.4.1/ext/oci8/oci8.c:69:
えーと、、
ociextp.hはrdbms/publicに、そのほかはdemo以下にあるみたい。それぞれ移してきます。
$ /usr/local/bin/make n file included from /usr/include/oci.h:2172, from /export/home2/hoge/php/php-4.4.1/ext/oci8/php_oci8.h:52, from /export/home2/hoge/php/php-4.4.1/ext/oci8/oci8.c:69: /usr/include/ociap.h:193:17: error: nzt.h: No such file or directory
はぁ、これもrdbms/publicにあるみたいです。気を取り直して再度make。
$ /usr/local/bin/make n file included from /usr/include/ociap.h:193, from /usr/include/oci.h:2172, from /export/home2/hoge/php/php-4.4.1/ext/oci8/php_oci8.h:52, from /export/home2/hoge/php/php-4.4.1/ext/oci8/oci8.c:69: /usr/include/nzt.h:143:50: error: nzerror.h: No such file or directory
これもrdbms/publicですね。もうこれで最後かな。
$ /usr/local/bin/make (中略) ld: fatal: library -lclntsh: not found ld: fatal: File processing errors. No output written to .libs/libphp4.so make: *** [libphp4.la] Error 1
そうか。libclntsh.so.10.1はあるけど、libclntsh.soはないね。
作ってあげよう。
# ln -s libclntsh.so.10.1 libclntsh.so
ようやくmakeできた。
えーと総合すると必要なインクルードファイルは
rdbms/demo以下では
- oci.h
- oratypes.h
- ocidfn.h
- oci1.h
- oro.h
- ori.h
- orl.h
- ort.h
- ociapr.h
- ociap.h
- oci8dp.h
- ocixad.h
- ocixmldb.h
rdbms/public以下では
- nzerror.h
- nzt.h
- ociextp.h
これらのインクルードファイルをサーバから持ってきて、さらにlibclntsh.so.10.1.soをlibclntsh.soにリンクすることが必要だってことですな。