PHP5をソースからインストールしてOracleと接続

PHPからOracleに接続したい.PDOを使えば楽そうだが,昔のプログラムがadodbで動いているので,ソースからインストール.

以下参照
PHPOracle Databaseを使う(導入編):CodeZine http://codezine.jp/a/article/aid/1335.aspx

CentOS 5.2
PHP 5.2.6

Oracle Instant client が必要.

yum では,oci8のパッケージが無いっぽい.
ソースを落としてくる.
途中zlib やらopensslやらが無いといわれるので,
$ sudo yum install zlib-devel

make オプションは以下の通り
./configure --build=i686-redhat-linux-gnu --host=i686-redhat-linux-gnu --target=i386-redhat-linux-gnu --program-prefix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/usr/com --mandir=/usr/share/man --infodir=/usr/share/info --cache-file=../config.cache --with-libdir=lib --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --disable-debug --with-pic --disable-rpath --without-pear --with-bz2 --with-curl --with-exec-dir=/usr/bin --with-freetype-dir=/usr --with-png-dir=/usr --enable-gd-native-ttf --without-gdbm --with-gettext --with-gmp --with-iconv --with-jpeg-dir=/usr --with-openssl --with-png --with-pspell --with-expat-dir=/usr --with-pcre-regex=/usr --with-zlib --with-layout=GNU --enable-exif --enable-ftp --enable-magic-quotes --enable-sockets --enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-track-vars --enable-trans-sid --enable-yp --enable-wddx --with-kerberos --enable-ucd-snmp-hack --with-unixODBC=shared,/usr --enable-memory-limit --enable-shmop --enable-calendar --enable-dbx --enable-dio --with-mime-magic=/usr/share/file/magic.mime --with-sqlite --with-libxml-dir=/usr --with-xml --with-system-tzdata --with-apxs2=/usr/sbin/apxs --without-mysql --with-gd --without-odbc --disable-dom --disable-dba --without-unixODBC --disable-pdo --disable-xmlreader --disable-xmlwriter --with-oci8=instantclient,/usr/local/lib/instantclient_10_2

以下のようなエラーが出た
/usr/bin/ld: warning: libnnz10.so, needed by /usr/local/lib/instantclient_10_2/libclntsh.so, not found (try using -rpath or -rpath-link)

libclntsh.soが見えないよーとのことなので,
$ export LD_LIBRARY_PATH=/usr/local/lib/instantclient_10_2:$LD_LIBRARY_PATH
$ make test
何か失敗してるけど..
$ make install
OK!

apache をリスタートするが,エラー.
LD_LIBRARY_PATHの設定を /etc/init.d/httpd に書く.
(上記はApacheの envvars に書けとあるけど,見つからないので)

apache を再度リスタートしてOK.

参考:
LD_LIBRARY_PATHとは?

OSが使用する変数です。リンク時または実行時にリンクする共有ライブラリを探すために使用されます。

LD_LIBRARY_PATHが設定されていない場合、ダイナミックローダーは/libや/usr/lib等に存在するライブラリを検索しますが、それ以外の場所に存在するライブラリを見つける事ができません。

実行プログラムが32ビットの場合はLD_LIBRARY_PATHが、64ビットの場合でLD_LIBRARY_PATH_64が設定されている場合はこちらが使用されます。

なお、リンク時パスや実行時パスはコンパイル時に設定することもできます。