メニュー
プロフィール
最近の記事
カテゴリ分類
記事一覧
FOR ENGINEERS
 
注目! テレビや雑誌でも紹介されているペン型ICレコーダー

PHP5.2と5.3
WindowsでPHPを使おうと思うのだが、この時期、「5.2」と「5.3」のどちらを使うべきか、迷っている。

「5.2」の方は大分枯れてきていて安定してるが、「5.3」の方はつい先日5/4に「5.3.2」にバージョンアップしたばかり。

とはいえ「5.3」の新機能も魅力的だし、今後の事を考えると、やはり「5.3」にするべきだろうか。

Apache + PHP5.3(Thread Safe)

ちょっと考えてしまっている。

| ネット関連::PHP | 09:41 AM | comments (x) | trackback (x) |
RedHat Enterprise Linux 5.2 で動かしている Oracle11gデータベースに対し、
PHPからOCI8でアクセスしたい。

●オラクルのバージョンは 11.1.0.6.0
●PHPのバージョンは 5.1.6-20

以前に作業した RHEL5 + Oracle10gR2 環境で PHPを使えるようにする作業に習って作業したのだが、うまく行かなかった。
【RHEL5】PHP から Oracle DB にアクセスする
この方法はPHPをソースコードから再コンパイルするので、
ついでに最新のPHPバージョンにアップデートできるというメリットもあるのだが、
セットアップできないのでは話にならない。

そのため peclを使う方法で作業する事にした。

この場合、既にPHPがセットアップされていないといけない。
従ってディストリビューションに含まれるPHPをセットアップしておく。

以下、rootにて。
# cd /media/..   # DVDドライブに移動
# cd Server
# rpm -ivh php-*
以上でPHPをセットアップ。

以下、OCI8をセットアップする。
ソースコードからコンパイルする手順に比べると、はるかに簡単です。
OCI8のセットアップでは、Instant Clientを使う方法もあるが、
このサーバーには既に Oracle11g (11.1.0.6.0)がセットアップされているので、これを使いたい。
そのため、以下のように作業する。
# pecl install oci8
downloading oci8-1.3.4.tgz ...
Starting to download oci8-1.3.4.tgz (134,240 bytes)
.....done: 134,240 bytes
10 source files, building
running: phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20050922
Zend Extension Api No: 220051025
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "ja_JP.UTF-8",
LANG = "ja_JP.SJIS"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "ja_JP.UTF-8",
LANG = "ja_JP.SJIS"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
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] : /u01/app/oracle/product/11.1.0/db_1
building in /var/tmp/pear-build-root/oci8-1.3.4
running: /tmp/tmppRhDk7/oci8-1.3.4/configure --with-oci8=/u01/app/oracle/product/11.1.0/db_1
checking for egrep... grep -E
checking for a sed that does not truncate output... /bin/sed
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking whether gcc and cc understand -c and -o together... yes
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... i686-redhat-linux-gnu
checking host system type... i686-redhat-linux-gnu
checking target system type... i686-redhat-linux-gnu
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext
checking for PHP extension directory... /usr/lib/php/modules
checking for PHP installed headers prefix... /usr/include/php
checking for re2c... no
configure: WARNING: You will need re2c 0.9.11 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking for Oracle (OCI8) support... yes, shared
checking PHP version... 5.1.6, ok
checking Oracle Install Directory... /u01/app/oracle/product/11.1.0/db_1
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for long int... yes
checking size of long int... 4
checking if we're on a 64-bit platform... no
checking OCI8 libraries dir... lib
checking Oracle version... 11.1
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for /usr/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm -B
checking whether ln -s works... yes
checking how to recognise dependent libraries... pass_all
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking how to run the C++ preprocessor... g++ -E
checking for g77... g77
checking whether we are using the GNU Fortran 77 compiler... yes
checking whether g77 accepts -g... yes
checking the maximum length of command line arguments... 32768
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC
checking if gcc PIC flag -fPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking whether the gcc linker (/usr/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
configure: creating libtool
appending configuration tag "CXX" to libtool
checking for ld used by g++... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes
checking for g++ option to produce PIC... -fPIC
checking if g++ PIC flag -fPIC works... yes
checking if g++ static flag -static works... yes
checking if g++ supports -c -o file.o... yes
checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
appending configuration tag "F77" to libtool
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
checking for g77 option to produce PIC... -fPIC
checking if g77 PIC flag -fPIC works... yes
checking if g77 static flag -static works... yes
checking if g77 supports -c -o file.o... yes
checking whether the g77 linker (/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
configure: creating ./config.status
config.status: creating config.h
running: make
/bin/sh /var/tmp/pear-build-root/oci8-1.3.4/libtool --mode=compile gcc -I. -I/tmp/tmppRhDk7/oci8-1.3.4 -DPHP_ATOM_INC -I/var/tmp/pear-build-root/oci8-1.3.4/include -I/var/tmp/pear-build-root/oci8-1.3.4/main -I/tmp/tmppRhDk7/oci8-1.3.4 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/u01/app/oracle/product/11.1.0/db_1/rdbms/public -I/u01/app/oracle/product/11.1.0/db_1/rdbms/demo -DHAVE_CONFIG_H -g -O2 -c /tmp/tmppRhDk7/oci8-1.3.4/oci8.c -o oci8.lo
mkdir .libs
gcc -I. -I/tmp/tmppRhDk7/oci8-1.3.4 -DPHP_ATOM_INC -I/var/tmp/pear-build-root/oci8-1.3.4/include -I/var/tmp/pear-build-root/oci8-1.3.4/main -I/tmp/tmppRhDk7/oci8-1.3.4 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/u01/app/oracle/product/11.1.0/db_1/rdbms/public -I/u01/app/oracle/product/11.1.0/db_1/rdbms/demo -DHAVE_CONFIG_H -g -O2 -c /tmp/tmppRhDk7/oci8-1.3.4/oci8.c -fPIC -DPIC -o .libs/oci8.o
/bin/sh /var/tmp/pear-build-root/oci8-1.3.4/libtool --mode=compile gcc -I. -I/tmp/tmppRhDk7/oci8-1.3.4 -DPHP_ATOM_INC -I/var/tmp/pear-build-root/oci8-1.3.4/include -I/var/tmp/pear-build-root/oci8-1.3.4/main -I/tmp/tmppRhDk7/oci8-1.3.4 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/u01/app/oracle/product/11.1.0/db_1/rdbms/public -I/u01/app/oracle/product/11.1.0/db_1/rdbms/demo -DHAVE_CONFIG_H -g -O2 -c /tmp/tmppRhDk7/oci8-1.3.4/oci8_lob.c -o oci8_lob.lo
gcc -I. -I/tmp/tmppRhDk7/oci8-1.3.4 -DPHP_ATOM_INC -I/var/tmp/pear-build-root/oci8-1.3.4/include -I/var/tmp/pear-build-root/oci8-1.3.4/main -I/tmp/tmppRhDk7/oci8-1.3.4 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/u01/app/oracle/product/11.1.0/db_1/rdbms/public -I/u01/app/oracle/product/11.1.0/db_1/rdbms/demo -DHAVE_CONFIG_H -g -O2 -c /tmp/tmppRhDk7/oci8-1.3.4/oci8_lob.c -fPIC -DPIC -o .libs/oci8_lob.o
/bin/sh /var/tmp/pear-build-root/oci8-1.3.4/libtool --mode=compile gcc -I. -I/tmp/tmppRhDk7/oci8-1.3.4 -DPHP_ATOM_INC -I/var/tmp/pear-build-root/oci8-1.3.4/include -I/var/tmp/pear-build-root/oci8-1.3.4/main -I/tmp/tmppRhDk7/oci8-1.3.4 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/u01/app/oracle/product/11.1.0/db_1/rdbms/public -I/u01/app/oracle/product/11.1.0/db_1/rdbms/demo -DHAVE_CONFIG_H -g -O2 -c /tmp/tmppRhDk7/oci8-1.3.4/oci8_statement.c -o oci8_statement.lo
gcc -I. -I/tmp/tmppRhDk7/oci8-1.3.4 -DPHP_ATOM_INC -I/var/tmp/pear-build-root/oci8-1.3.4/include -I/var/tmp/pear-build-root/oci8-1.3.4/main -I/tmp/tmppRhDk7/oci8-1.3.4 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/u01/app/oracle/product/11.1.0/db_1/rdbms/public -I/u01/app/oracle/product/11.1.0/db_1/rdbms/demo -DHAVE_CONFIG_H -g -O2 -c /tmp/tmppRhDk7/oci8-1.3.4/oci8_statement.c -fPIC -DPIC -o .libs/oci8_statement.o
/bin/sh /var/tmp/pear-build-root/oci8-1.3.4/libtool --mode=compile gcc -I. -I/tmp/tmppRhDk7/oci8-1.3.4 -DPHP_ATOM_INC -I/var/tmp/pear-build-root/oci8-1.3.4/include -I/var/tmp/pear-build-root/oci8-1.3.4/main -I/tmp/tmppRhDk7/oci8-1.3.4 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/u01/app/oracle/product/11.1.0/db_1/rdbms/public -I/u01/app/oracle/product/11.1.0/db_1/rdbms/demo -DHAVE_CONFIG_H -g -O2 -c /tmp/tmppRhDk7/oci8-1.3.4/oci8_collection.c -o oci8_collection.lo
gcc -I. -I/tmp/tmppRhDk7/oci8-1.3.4 -DPHP_ATOM_INC -I/var/tmp/pear-build-root/oci8-1.3.4/include -I/var/tmp/pear-build-root/oci8-1.3.4/main -I/tmp/tmppRhDk7/oci8-1.3.4 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/u01/app/oracle/product/11.1.0/db_1/rdbms/public -I/u01/app/oracle/product/11.1.0/db_1/rdbms/demo -DHAVE_CONFIG_H -g -O2 -c /tmp/tmppRhDk7/oci8-1.3.4/oci8_collection.c -fPIC -DPIC -o .libs/oci8_collection.o
/bin/sh /var/tmp/pear-build-root/oci8-1.3.4/libtool --mode=compile gcc -I. -I/tmp/tmppRhDk7/oci8-1.3.4 -DPHP_ATOM_INC -I/var/tmp/pear-build-root/oci8-1.3.4/include -I/var/tmp/pear-build-root/oci8-1.3.4/main -I/tmp/tmppRhDk7/oci8-1.3.4 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/u01/app/oracle/product/11.1.0/db_1/rdbms/public -I/u01/app/oracle/product/11.1.0/db_1/rdbms/demo -DHAVE_CONFIG_H -g -O2 -c /tmp/tmppRhDk7/oci8-1.3.4/oci8_interface.c -o oci8_interface.lo
gcc -I. -I/tmp/tmppRhDk7/oci8-1.3.4 -DPHP_ATOM_INC -I/var/tmp/pear-build-root/oci8-1.3.4/include -I/var/tmp/pear-build-root/oci8-1.3.4/main -I/tmp/tmppRhDk7/oci8-1.3.4 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/u01/app/oracle/product/11.1.0/db_1/rdbms/public -I/u01/app/oracle/product/11.1.0/db_1/rdbms/demo -DHAVE_CONFIG_H -g -O2 -c /tmp/tmppRhDk7/oci8-1.3.4/oci8_interface.c -fPIC -DPIC -o .libs/oci8_interface.o
/bin/sh /var/tmp/pear-build-root/oci8-1.3.4/libtool --mode=link gcc -DPHP_ATOM_INC -I/var/tmp/pear-build-root/oci8-1.3.4/include -I/var/tmp/pear-build-root/oci8-1.3.4/main -I/tmp/tmppRhDk7/oci8-1.3.4 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/u01/app/oracle/product/11.1.0/db_1/rdbms/public -I/u01/app/oracle/product/11.1.0/db_1/rdbms/demo -DHAVE_CONFIG_H -g -O2 -o oci8.la -export-dynamic -avoid-version -prefer-pic -module -rpath /var/tmp/pear-build-root/oci8-1.3.4/modules oci8.lo oci8_lob.lo oci8_statement.lo oci8_collection.lo oci8_interface.lo -Wl,-rpath,/u01/app/oracle/product/11.1.0/db_1/lib -L/u01/app/oracle/product/11.1.0/db_1/lib -lclntsh
gcc -shared .libs/oci8.o .libs/oci8_lob.o .libs/oci8_statement.o .libs/oci8_collection.o .libs/oci8_interface.o -L/u01/app/oracle/product/11.1.0/db_1/lib -lclntsh -Wl,-rpath -Wl,/u01/app/oracle/product/11.1.0/db_1/lib -Wl,-soname -Wl,oci8.so -o .libs/oci8.so
creating oci8.la
(cd .libs && rm -f oci8.la && ln -s ../oci8.la oci8.la)
/bin/sh /var/tmp/pear-build-root/oci8-1.3.4/libtool --mode=install cp ./oci8.la /var/tmp/pear-build-root/oci8-1.3.4/modules
cp ./.libs/oci8.so /var/tmp/pear-build-root/oci8-1.3.4/modules/oci8.so
cp ./.libs/oci8.lai /var/tmp/pear-build-root/oci8-1.3.4/modules/oci8.la
PATH="$PATH:/sbin" ldconfig -n /var/tmp/pear-build-root/oci8-1.3.4/modules
----------------------------------------------------------------------
Libraries have been installed in:
/var/tmp/pear-build-root/oci8-1.3.4/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,--rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
(It is safe to ignore warnings about tempnam and tmpnam).

running: make INSTALL_ROOT="/var/tmp/pear-build-root/install-oci8-1.3.4" install
Installing shared extensions: /var/tmp/pear-build-root/install-oci8-1.3.4/usr/lib/php/modules/
running: find "/var/tmp/pear-build-root/install-oci8-1.3.4" -ls
6881724 4 drwxr-xr-x 3 root root 4096 Jan 28 15:11 /var/tmp/pear-build-root/install-oci8-1.3.4
6881753 4 drwxr-xr-x 3 root root 4096 Jan 28 15:11 /var/tmp/pear-build-root/install-oci8-1.3.4/usr
6881754 4 drwxr-xr-x 3 root root 4096 Jan 28 15:11 /var/tmp/pear-build-root/install-oci8-1.3.4/usr/lib
6881755 4 drwxr-xr-x 3 root root 4096 Jan 28 15:11 /var/tmp/pear-build-root/install-oci8-1.3.4/usr/lib/php
6881756 4 drwxr-xr-x 2 root root 4096 Jan 28 15:11 /var/tmp/pear-build-root/install-oci8-1.3.4/usr/lib/php/modules
6881752 384 -rwxr-xr-x 1 root root 388194 Jan 28 15:11 /var/tmp/pear-build-root/install-oci8-1.3.4/usr/lib/php/modules/oci8.so

Build process completed successfully
Installing '/var/tmp/pear-build-root/install-oci8-1.3.4//usr/lib/php/modules/oci8.so'
install ok: channel://pecl.php.net/oci8-1.3.4
You should add "extension=oci8.so" to php.ini
以上にて oci8.so が正常にセットアップされました。
引き続き PHPにoci8の設定を加え、apacheを再起動します。
# echo "extension=oci8.so" > /etc/php.d/oci8.ini
# service httpd restart
これで phpinfo ()を呼び出して「oci8」がロードされているかどうか確認します。

また apache の実行ユーザーの環境変数に ORACLE_HOME が設定する必要があるので、以下の設定を登録しておく。
#vi /etc/syscofig/httpd

--- begin httpd
...
#↓最後に以下を追加
export NLS_LANG=Japanese_Japan.JA16SJISTILDE
export ORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1
export ORACLE_SID=サービス名

--- end httpd

# service httpd restart



参考)
【PHP】Instant Client+peclでoci8(oracle)関数を使えるようにする

| ネット関連::PHP | 05:45 PM | comments (x) | trackback (x) |
RedHat Enterprise Linux 5.0 で Oracle 10gR2 を運用している。

このサーバーのOracle DB に WEB 経由でアクセスできるようにするため、
Apache と PHP をセットアップする。

セットアップするパッケージとそのバージョンは以下の通り。
●Apacheは、RPMパッケージ 2.2.3-6
●PHPは、ソースコードから 5.2.5 (RHEL5で配布しているRPMパッケージでは5.1.6)
●Oracleは、10gR2(10.2.0.1.0) for Linux 32bit

ボックス1 セットアップの方針と概要
●Apache は RHEL のディストリビューションに含まれる rpm を使う
サーバーにRedHat Enterprise Linux 5をインストールする際に 、同時にApache をインストールしているが、apxs をインストールしていない。
そのためhttpd-develを追加でインストールする。
httpd-develのrpmパッケージはRHELのディストリビューションDVDに含まれる
「httpd-devel-2.2.3-6.el5」を使う。
※Apacheをインストールしていない場合でも追加でインストールすれば問題ない。

●PHP はソースコードからコンパイルするが、Oracle Instant Client は使わない
※既にインストール済みのOracle 10gを使う
Apacheと同様、RHELインストール時にPHPもインストールしているものの、これをアンインストールし、ソースからコンパイルしてインストールする。
rootユーザーにて
# rpm -aq|grep php
を実行して表示される全てのパッケージをアンインストールする。

! アンインストールの前に
PHPをソースからMakeする時のコンフィギュレーションは、(これからアンインストールするのだが)現在、既にインストールされているPHPのコンフィギュレーション(コンパイル・オプション)をなるべく反映させる。
そのため、アンインストールの前に、phpinfo()を使って、現在のコンパイル・オプションを把握しておき、改めてコンパイルする際に、このオプションと同時にORACLE (OCI8)の設定を追加する。
※後述のオプション参照。

という事でPHPをアンインストールする。
# rpm -e php-5.1.6-5.el5
# rpm -e …
※依存関係を考慮しアンインストールする順番も考慮に入れる事。


ボックス1 Apache のインストール
・RHEL をインストールする際に、httpd サービスをインストールしていない場合
 以下のパッケージを追加する。httpdサービスをインストールしている場合でも
 その他にhttpd-devel が必要となるので、追加でインストールする。

・DVD ドライブに RedHat Enterprise Linux 5.0 のセットアップDVDを挿入し、
 「/media/RHEL_5 i386 DVD」にマウントされているとする。
rootユーザーにて以下を実行する。
# cd /media/RHEL_5\ i386\ DVD\Server
# rpm -ivh httpd-2.2.3-6.el5.rpm
  ・・・ httpd をインストールしていない場合、インストールする
# rpm -ivh httpd-devel-2.2.3-6.el5.rpm
  ・・・ apxs をインストールしていない場合、インストールする
※apacheのパッケージがインストールされているか否かは以下のように確認する
# rpm -aq|grep httpd
httpd-manual-2.2.3-6.el5
httpd-2.2.3-6.el5
httpd-devel-2.2.3-6.el5
のように表示されれば、既にインストールされている状態。

ボックス1 PHPのセットアップ
2008.04.16時点でのPHPの最新バージョンは「5.2.5」
●PHPソース・アーカイブのダウンロード
rootユーザーにて、
# mkdir -p ~/rpm/php
# cd ~/rpm/php
# wget http://jp.php.net/get/php-5.2.5.tar.gz/from/this/mirror
# ls
php-5.2.5.tar.gz
# tar -xvzf php-5.2.5.tar.gz
# ls
php-5.2.5 php-5.2.5.tar.gz

●Configuration と Make
# cd php-5.2.5
# vi conf.sh
--- 以下 conf.sh の内容 ---
#!/bin/bash
./configure \
--build=i386-redhat-linux\
--host=i386-redhat-linux\
--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-expat-dir=/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=/etc/httpd/conf/magic\
--without-sqlite\
--with-libxml-dir=/usr\
--with-xml\
--with-apxs2=/usr/sbin/apxs\
--without-mysql\
--without-gd\
--without-odbc\
--disable-dom\
--disable-dba\
--without-unixODBC\
--disable-pdo\
--disable-xmlreader\
--disable-xmlwriter\
--with-oci8=/u01/app/oracle/oracle/product/10.2.0/db_1\
--enable-mbstring\
--enable-zend-multibyte
--- 以上 conf.sh の内容 ---
青字の部分は ORACLE をセットアップしているフォルダで、
 いわゆる環境変数 ORACLE_HOME として定義されているディレクトリ。例えば、
# echo $ORACLE_HOME
のようにして表示されるフォルダ。
Configurationを実行する。
# chmod +x conf.sh
# ./conf.sh
上記の設定で実行すると、以下のように叱られるので、
特に必要が無ければ、これらのオプションは外した方がよいかも。
Notice: Following unknown configure options were used:

--with-png
--with-expat-dir=/usr
--enable-track-vars
--enable-trans-sid
--enable-yp
--enable-memory-limit
--enable-dbx
--enable-dio
--with-xml
--without-odbc
makeしてインストールする。
# make && make install


ボックス1 Apacheの設定ファイル(/etc/httpd/conf/httpd.conf)の調整
rootユーザーにて
# vi /etc/httpd/conf/httpd.conf
--- 以下 httpd.conf ---


LoadModule php5_module /usr/lib/httpd/modules/libphp5.so
# ↑LoadModule がかたまって記述されている場所の最後あたりに、上記の行を追加する



AddHandler php5-script .php
AddType application/x-httpd-php-source .phps
AddType application/php x-httpd-php .php
# ↑AddType application/x-gzip .gz .tgz が定義されている場所の下あたりに、上記の行を追加する


--- 以上 httpd.conf ---


ボックス1 PHPの設定ファイル(/etc/php.ini)の調整
rootユーザーにて
# vi /etc/php.ini
--- 以下 php.ini ---


extension=php_oci8.dll
; ↑先頭のセミコロン(;)を削る



extension=php_pdo_oci.dll
extension=php_pdo_oci8.dll
; ↑先頭のセミコロン(;)を削る


[OCI8」
; ↑必要に応じ、このセクション内のパラメータを変更する

--- 以上 php.ini ---

ボックス1 Apache起動時の設定ファイル(/etc/sysconfig/httpd)の調整

rootユーザーにて
# vi /etc/sysconfig/httpd
--- 以下 httpd ---
# Configuration file for the httpd service.

#
# The default processing model (MPM) is the process-based
# 'prefork' model. A thread-based model, 'worker', is also
# available, but does not work with some modules (such as PHP).
# The service must be stopped before changing this variable.
#
#HTTPD=/usr/sbin/httpd.worker

#
# To pass additional options (for instance, -D definitions) to the
# httpd binary at startup, set OPTIONS here.
#
#OPTIONS=

#
# By default, the httpd process is started in the C locale; to
# change the locale in which the server runs, the HTTPD_LANG
# variable can be set.
#
#HTTPD_LANG=C

export NLS_LANG=Japanese_Japan.JA16SJISTILDE
export ORACLE_HOME=/u01/app/oracle/oracle/product/10.2.0/db_1
export ORACLE_SID=test
# ↑上記のようなORACLEの環境変数を追加する

--- 以上 httpd ---

ボックス1 必要に応じ oinstall グループを追加
ユーザ権限の問題で、エラーが発生する場合がある。
<?php

$dbuser = "…";
$dbpswd = "…";
$dbservice = "…";
$con = OCILogon($dbuser, $dbpswd, $dbservice);

?>
のようにしてORACLEにアクセスしようとした時に、
Warning: ocilogon() [function.ocilogon]: OCIEnvNlsCreate() failed. There is something wrong with your system - please check that ORACLE_HOME is set and points to the right directory in /var/www/html/include.phl on line 18
のようなエラーメッセージが発生する場合、apache ユーザーをoinstallグループに加える。
rootユーザーにて、/etc/group を編集し、oinstallグループの後尾にapacheユーザーを追加する。

ボックス1 Apacheの再起動
rootユーザーにて
# /etc/rc.d/init.d/httpd restart

ボックス1 動作確認
確認用スクリプトを作成する。
<?php
phpinfo();
?>

ブラウザでアクセスし、PHPのOCIが下図のように設定されていればOK。



| ネット関連::PHP | 02:06 PM | comments (x) | trackback (x) |
ローカルWindows端末でPHPを開発するための環境として、
「Win32 + Apache + PHP」
を使っています。

ここで、最近PEARを使おうと思い(PHPと共に既にセットアップされている)
c:\php5\pear.bat
を実行すると、
OCI.dllが見つからなかったため、このアプリケーションを開始できませんでした。アプリケーションをインストールし直すとこの問題は解決される場合があります。
というエラーメッセージが表示される事に
気がつきました。

要するに「Oracle」をインストールしていないので、
OCI.dllがローカル環境に存在しないのですが、
それにも関わらず OCI.dllを呼び出す2つのDLL
php_oci8.dll、php_pdo_oci8.dll
を使う設定になっていたためでした。

これまで、このdllを使わなかったので気がつかなかっただけです。

当面Oracleを使う事は無いので、「php.ini」ファイルのモジュール拡張定義を修正
extension=php_oci8.dll
extension=php_pdo_oci8.dll

の2行を以下のようにコメントアウト、
;extension=php_oci8.dll
;extension=php_pdo_oci8.dll


これでpear.batを実行してもエラーメッセージが表示されなくなりました。
ちなみにpear.batを正常に動作させるためには、
環境変数PATHにc:\php5\ext(phpの拡張モジュールのディレクトリ)を記述する必要があります。
一時的に実行するだけなら、環境変数に追加。
set PATH=%PATH%;c:\php5\ext

恒常的に設定するなら、
■「マイコンピュータ」(右クリック)→「プロパティ」
■「システムのプロパティ」→「詳細設定」→「環境変数ボタン」
■「システム環境変数」→「PATH」に「c:\php5\ext」を追加




| ネット関連::PHP | 11:40 PM | comments (0) | trackback (2447) |
PAGE TOP ↑