«xrea で tDiary を正常に動かす.. メイン 噂の Groovy を WebObjects で使..»

日々是横着

全文検索:% grep '' *.td2

アンテナでの更新チェックには、antenna.lirs か、index.rdf をご利用ください。


[wo][vine] Vine Linux 2.6r4 に WebObjects 5.2.3 デプロイ環境構築

Last updated: 2005-08-11T00:50:46

方針

  • インストールは /opt/Apple 以下に行います。他の場所へのインストールも 可能ですが、その場合、過去に問題が起きたことがあるという報告があるの で、無難に /opt/Apple 以下にします。
  • apache は Vine 標準の 1.3.x を使います。 現時点では WebObjects 標準のアダプタは apache 2.0 系を サポートしていません。
    • 標準じゃないアダプタがあるようですが、私は使ったことがないので よくわかりません。
  • apache のドキュメントルートは /home/httpd/html とします。
  • cgi-bin は /home/httpd/cgi-bin とします。
  • Java は Sun の 1.4.2_04 を使います。/usr/local/java 以下に インストールしてあります。
  • 基本的に以下のページを参考にさせて頂きつつ作業します。
  • 今回の作業は全てユーザ root で行っています。

環境

# httpd -v
Server version: Apache/1.3.27 (Unix)  (Vine/Linux)
Server built:   Oct 29 2003 07:20:43
# /usr/local/java/bin/java -version 
java version "1.4.2_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode)

インストール

まずは、 WebObjects 5.2 Windows & Solaris の CD-ROM を入れ、 必要なファイルをインストールします。

# mount -t iso9660 -o nojoliet -o norock -o map=o /dev/cdrom /mnt/cdrom
mount: ブロックデバイス /dev/cdrom は書き込み禁止です、読込み専用で
マウントしま す
# cd /mnt/cdrom/Deployment/SOLARIS/

java へのパスが通っているか確認。

# which java

通ってない場合は、

install.sh: Unable to locate java virtual machine.  If you have
            a JVM installed, try using the `-altjvm <PATH>' flag,
            or type `install.sh -help' for more information.

というエラーが出るので、予め PATH の設定をしておくと良い。 もちろん上記エラーの言うように -altjvm をいうオプションを指定しても 良いと思います。

# 設定
# export PATH=/usr/local/java/bin:$PATH
# 確認
# echo $PATH  

インストーラを走らせる。 このインストーラの実行は数分で終わる。 「B-111-AAA-111-AAA-111-AAA-111-AAA-111」の部分は、ご自分のパッケージに入っている「デプロイ用」のシリアルナンバーに置き換えて実行してください。

# ./install.sh -license B-111-AAA-111-AAA-111-AAA-111-AAA-111 \
    -adaptorsOnly NO -minimalInstall NO -cgibin /home/httpd/cgi-bin \
    -docroot /home/httpd/html -woroot /opt/Apple

「サポート外のシステムなので起動スクリプトは作れないよ。 自分で何とかしてね。」というアラートがでる。 これは後述「起動スクリプトの作成」で対処を行う。

WO SERVICES:
    Most WebObjects applications require some support services to be
  running.  You can start them manually by executing:
  `/opt/Apple/Library/WebObjects/Executables/WOServices start'.

    Startup scripts are used to have WebObjects services start
  at every reboot.  However, because your operating system is unsupported,
  neither the installer nor the WOServices executable will be able to
  configure this for you.  However, only simple modification of a utility
  Bourne shell script is required to allow WOServices to create these
  startup scripts for your system.  Please refer to WOServices and
  `/opt/Apple/Library/WebObjects/Executables/WOServices_utils.sh'.

「httpd.conf に以下の行を追加しなさい」というアラートが出る。 実はここで表示されているパス(/opt/Apple/Library/WebObjects/Adaptors/Apache/apache.conf)は間違っているが、諸々含めて後述の 「apache の設定」で設定を行う。

APACHE WEBSERVER NOTE:
    If you are using the Apache Webserver, you will need the WebObjects 
  `apache.conf'. This installation's `apache.conf' file can be found at:
  /opt/Apple/Library/WebObjects/Adaptors/Apache/apache.conf

  The Apache Webserver `httpd.conf' file (found in the Apache `httpd' directory)
  needs to be made aware of this file. Add the following line to `httpd.conf':
  Include /opt/Apple/Library/WebObjects/Adaptors/Apache/apache.conf

「サポート外のシステムだから、アダプタのバイナリはインストールしなかった よ。自分でビルドしてくれ。」というアラートが出る。 これも後述 「apache 用アダプタのビルド 」で対応する。

UNSUPPORTED OPERATING SYSTEM:
    Your operating system is unsupported, so no WebObjects Adaptors binaries
  were installed.  However, the adaptor source code was installed into 
  `/opt/Apple/Developer/Examples/WebObjects/Source/Adaptors/', 
  so you can build executables yourself (copy them into your webserver's
  cgi-bin directory).

「NEXT_ROOT 環境変数を設定しましょう」というアラートがでる。後述 「環境変数 NEXT_ROOT の設定」で設定する。

NEXT_ROOT ENVIRONMENT VARIABLE:
    In order for WebObjects services to function, you should define the
  environment variable NEXT_ROOT in your shell startup script.  It should
  be set to '/opt/Apple' (without the apostrophes).

  WebObjects 5.2 Deployment, Full Install is now installed.

パッケージの箱の「システム要件」に

1GB 以上の空きハードディスク容量

なんて書いてあったので、インストール完了時点でのディスク使用量を 調べてみる。

# du -sk /opt
42593   /opt

40 メガぐらい。全然大したことないね。どうやら 1ギガというのは Mac 向けの話のようだ。

ここでインストールされるファイルは、主に、JavaMonitor とか wotaskd の 実行ファイルと、apache 用アダプタのソースコードです。

環境変数 NEXT_ROOT の設定

参考文献 [1] では /etc/profile.local と書かれているがこれは Suse Linux のもの。 Vine は /etc/profile に設定を書く。

# まず設定
# export NEXT_ROOT=/opt/Apple
# 確認
# echo $NEXT_ROOT
/opt/Apple
# /etc/profile に書き込み(もちろんエディタで追加しても良いです)
# echo "export NEXT_ROOT=/opt/Apple" >> /etc/profile
# 確認
# tail /etc/profile

WebObjects のアップデート

必要に応じて、WebObjects 5.2.1, 5.2.2, 5.2.3 への アップデートパッチを適用します。

基本的に以下の Apple のドキュメントに従って作業します。

もし既に WebObjects や WebObjects 用のアダプタを組み込んだ apache が起動しているのなら、それらを全て止めてからアップデート しないといけないと書いてあるので、まずは全て止めます。

# apache 止める
# /etc/rc.d/init.d/httpd stop
# 確認
# ps ax | grep httpd

# WebObjects サービス止める(もし動いていれば)
# cd $NEXT_ROOT/Library/WebObjects/Executables
# ./WOServices stop
WebObjects services stopped.
# 確認
# ps -A -o args | grep -i wo

/opt/install/woupdate というディレクトリを作って、 ここにアップデート用のファイル群を取得します。

# mkdir -p /opt/install/woupdate
# cd /opt/install/woupdate

# patch インストールスクリプト "patcher" のダウンロード
# wget http://download.info.apple.com/Apple_Support_Area/\
Apple_Software_Updates/MultiCountry/Enterprise/scripts/patcher.sh

# 5.2.1 ダウンロード
# wget http://download.info.apple.com/Apple_Support_Area/\
Apple_Software_Updates/MultiCountry/Enterprise/webobjects/\
patches/5.2/WO521Solaris.TAR.Z
(約 16M)

# 5.2.2 ダウンロード
# wget http://download.info.apple.com/Apple_Support_Area/\
Apple_Software_Updates/MultiCountry/Enterprise/webobjects/\
patches/5.2/WO522Solaris.tar.gzip

(約 35M)

# 5.2.3 ダウンロード
# wget http://download.info.apple.com/Apple_Support_Area/\
Apple_Software_Updates/MultiCountry/Enterprise/webobjects/\
patches/5.2/WO523Solaris.tar.gzip
(約 16M)

patcher に

ERROR *** gnutar not in path

と言われるので、予め

ln -s /bin/tar /bin/gnutar

しておきます。

# 5.2.1 パッチあて
# time ./patcher.sh -install WO521Solaris.TAR.Z
No errors, extracting patch

Install of /opt/install/woupdate/WO521Solaris.TAR.Z successful

real    0m56.557s
user    0m28.610s
sys     0m24.740s

# 5.2.2 パッチあて
# time ./patcher.sh -install WO522Solaris.tar.gzip  
cp: `/tmp/gnutar' と `/tmp/gnutar' は同じファイルです
No errors, extracting patch

Install of /opt/install/woupdate/WO522Solaris.tar.gzip successful

real    4m24.508s
user    1m33.140s
sys     1m39.270

# 5.2.3 パッチあて
# time ./patcher.sh -install WO523Solaris.tar.gzip 
cp: `/tmp/gnutar' と `/tmp/gnutar' は同じファイルです
No errors, extracting patch

Install of /opt/install/woupdate/WO523Solaris.tar.gzip successful

real    0m59.609s
user    0m26.080s
sys     0m22.400s

更に、Apple のドキュメントに従って、 WebObjects 関連のファイルを /home/httpd/html 以下にコピーします。

Vine では cp は cp -i の alias になっていて、いちいち 「上書きしますか?」という確認がでてウザいので、 cp はフルパスで指定しています。

# /bin/cp -r $NEXT_ROOT/Library/WebObjects/WODocumentRoot/WebObjects \
/home/httpd/html/

apache 用アダプタのビルド

次に、apache 用の WebObjects アダプタをビルドしますが、 そのままではビルドできないので、Makefile やソースコードを 若干修正します。

make.config の編集

make.config に Linux 用の設定を付け加えます。 その前にまずは編集前のファイルのバックアップをしておきましょう。

# cd /opt/Apple/Developer/Examples/WebObjects/Source/Adaptors
# バックアップ
# cp -p make.config make.config.orig

そして、 make.config をエディタで開き、17 行目あたりに以下を追加。

# LINUX
ifeq "LINUX" "$(OS)"
ADAPTORS = CGI Apache
# Default path for apxs
APXS = /usr/sbin/apxs
endif

Makefile の編集

同様に、Makefile。 同じく最初に元ファイルのバックアップをしておきます。

# cd /opt/Apple/Developer/Examples/WebObjects/Source/Adaptors/Apache
# バックアップ
# cp -p Makefile Makefile.orig

Makefile をエディタで開いて、 30 行目以下からファイルの末尾までをバッサリ削除して、 代わりに以下を追加。

[tab] と書いてあるところはタブを入力してください。 Makefile ではタブには特別な意味があります。タブの代わりにスペースを 入力してはいけません。

基本的には参考文献 [1] と同じなのですが、

mod_WebObjects.o :

のビルド手順のところだけは、無駄と思われる箇所があったので 参考文献 [1] とは異なったものにしています。

ifeq "LINUX" "${OS}"
ENABLE_SSL_SUPPORT =
OPENSSL_INCL_FLAGS =
OPENSSL_LIB_FLAGS =
APACHE_INCL_FLAGS = -I/usr/include/apache
CFLAGS +=-DEAPI ${APACHE_INCL_FLAGS}
LDFLAGS += -G -L/lib -lc ${OPENSSL_LIB_FLAGS}
endif

CFLAGS += ${OPENSSL_INCL_FLAGS}
APXSFLAGS = -i

all: mod_WebObjects.so

mod_WebObjects.so : mod_WebObjects.o ${COMMON_OBJFILES}
[tab]ld ${LDFLAGS} mod_WebObjects.o ${COMMON_OBJFILES} -o mod_WebObjects.so
[tab]${APXS} ${APXSFLAGS} mod_WebObjects.so

# 以下は、他のドキュメントとは少し変えてある。
# 「リンクが完了しなかったのでリンカの入力ファイルは使われませんでした」
# というウォーニングが出ないようにするため。
mod_WebObjects.o : mod_WebObjects.c ${COMMON_OBJFILES}
[tab]${CC} -c ${CFLAGS} mod_WebObjects.c

clean:
[tab]rm -f mod_WebObjects.so mod_WebObjects.o *.o

include ../Adaptor/make.postamble

appcfg.c の編集

実はこの修正をしなくてもビルド通ってしまったのですが、 参考文献 [1] には修正する手順が入っており、 必要な理由(または不要な理由)がわからないので、 一応念のためやっておくことにしました。

元ファイルのバックアップ。

# cd $NEXT_ROOT/Developer/Examples/WebObjects/Source/Adaptors/Adaptor/
# バックアップ 
# cp -p appcfg.c appcfg.c.orig

52 行目から始まる以下の 3行をカットし(コピーじゃなく、カット!)

#ifndef MAXPATHLEN
#define MAXPATHLEN 255
#endif

72 行目辺りの #endif の下にペーストして、以下のようにします。

#include <arpa/inet.h>          /* inet_addr() */
#include <sys/param.h>
#endif
#ifndef MAXPATHLEN
#define MAXPATHLEN 255
#endif

make

これでようやく make ができます。

# cd /opt/Apple/Developer/Examples/WebObjects/Source/Adaptors
# 環境変数 OS の設定
# export OS=LINUX
# 確認
# echo $OS
LINUX
# ビルド
# time make clean all 2>&1 | tee /tmp/wo_adaptor_build.log
real    0m39.456s
user    0m36.820s
sys     0m2.140s

apache の設定

WebObjects 付属の apache.conf の書き換え

まずは、WebObjects 付属の apache.conf を若干書き換えます。

インストーラのアラートでは

Include /opt/Apple/Library/WebObjects/Adaptors/Apache/apache.conf

と書かれているが、このパスは間違っていて、実際には以下。

まずはバックアップ。

# cd /opt/Apple/Developer/Examples/WebObjects/Source/Adaptors/Apache/
# バックアップ
# cp -p apache.conf apache.conf.orig

apache.conf をエディタで開いて以下の 2 箇所の設定を書き換えます。

SYSTEM_LIBRARY_DIR/WebObjects/Adaptors/Apache/mod_WebObjects.so

/usr/lib/apache/mod_WebObjects.so

に書き換え。

LOCAL_LIBRARY_DIR/WebServer/Documents

/home/httpd/html

に書き換え。

これで、 apache.conf の修正は終了。

httpd.conf に設定追加

次に、/etc/httpd/conf/httpd.conf の末尾に以下を追加。

Include /opt/Apple/Developer/Examples/WebObjects/Source/Adaptors/Apache/apache.conf
<Location /cgi-bin/./>
SetHandler WebObjects
</Location>

以下はやらなくても動いちゃったよ?

参考文献 [1] に記述されているけど、やらなくても動いてしまったので、 とりあえずこれらは実行しないことにしました。

  • /etc/httpd/conf/httpd.confで、"LoadModule rewrite_module ..." という箇所を見付けて、それの直前に

    Include /usr/local/apache/conf/webobjects.conf
    <Location /cgi-bin/./>
    SetHandler WebObjects
    </Location>    

    を追加せよ、と書いてあるが、httpd.conf の末尾に追加しても (上記 httpd.conf に設定追加の手順のこと) 特にエラーなく動いている。

  • 同じく httpd.conf で "AddModule mod_rewrite.c" という箇所を見付けて、 その直後に

    AddModule mod_WebObjects.c

    と追加せよ、と書いてあるが追加しなくても(apache.conf に 書かれているので)オッケーだった。

  • apache.conf で "AddModule mod_WebObjects.c" の頭に "#" をつけて コメントアウトせよ、と書いてあるが、これは上記との兼ね合いで コメントアウトせずに使うことにした。

動作確認

apache 再起動

以上を全て行ったら、

# /etc/rc.d/init.d/httpd restart

で apache を再起動。

/var/log/messages や /var/log/httpd/ 以下のログを 見てエラーが出ていないか確認。

wotaskd の起動

# $NEXT_ROOT/Library/WebObjects/JavaApplications/wotaskd.woa/wotaskd &

JavaMonitor の起動

# $NEXT_ROOT/Library/WebObjects/JavaApplications/JavaMonitor.woa/JavaMonitor -WOPort 56789 &

後は、

http://yourhost.yourdomain.com:56789/
(とか http://localhost:56789/ とか)

にブラウザでアクセスして、 JavaMonitor の画面がでればオッケー。

起動スクリプトの作成

動作が確認できたら、参考文献 [2] に従って 起動スクリプトを作成/設置し、chkconfig なり ntsysv なりで WebObjects 関連のデーモンが自動起動するように設定。

その他

書籍

以下の書籍(洋書)にも Linux での deploy に関する記述がありますが、 実は 参考文献 [1] とほとんど同じ内容で す。っていうか、参考文献 [1] の方が 若干中身が濃いです。

Webobjects 5 for Mac OS X (Visual Quickpro Guide)Webobjects 5 for Mac OS X (Visual Quickpro Guide)

が、しかし、この本はものすごく基本的なことからしっかり解説してくれる 素晴しい書籍なので、WebObjects でバリバリ開発を行おうと思っている方は ぜひ購入をお勧めします。 英語苦手な方は、倉橋さんのセミナー受講した方が結果的 には安上がりかもしれませんけど、 こんなすごい本が 2000 円台で手に入るというのもスゴイことですよ。

JBoss

Xcode で .jar じゃなく .war を吐くようにして、 JBoss セットアップして .war を入れてあげれば、 WebObjects デプロイ環境なんかインストールしなくても良い、 しかもホットデプロイ可能だぜぃ、という噂もあるけど、本当?

今度、時間があったら試してみたいと思う。 っていうか、私、「JBoss って何?缶コーヒー?」って ぐらい全然知らないので、誰か試してレポートお願いします_o_

2004/05/09 追記

Tomcat でのデプロイの方法みつけた(未試行)。 <URL:http://www.tech-arts.co.jp/macosx/webobjects-jp/htdocs/2600/2614.html>

あと、以下の情報をみると、どっちにしろ WebObjects は入れなきゃいけなさそうにみえるが、さて。 <URL:http://til.info.apple.co.jp/cgi-bin/WebObjects/TechInfo.woa/wa/showTIL?id=51035>

2004/10/12 追記

Debian(Woody) の人はこっちも見ると良いかも。

私の 2004/10/01 の日記:mod_WebObjects.so が落ちる

その他にも Debian だと主にパスの指定回りなどで若干設定が異なりますが大方上記の手順で行けました。

パスの変更が必要だったのは以下。

make.config
  APXS = /usr/sbin/apxs
  -> APXS = /usr/bin/apxs
Makefile
  APACHE_INCL_FLAGS = -I/usr/include/apache
  -> APACHE_INCL_FLAGS = -I/usr/include/apache-1.3
apache.conf
  LoadModule WebObjects_module /usr/lib/apache/mod_WebObjects.so
  ->  LoadModule WebObjects_module /usr/lib/apache/1.3/mod_WebObjects.so
  /home/httpd/html
  -> /home/htdocs
2004/10/13 追記

やっぱり WebObjects のデプロイ環境をインストールしなくても WebObjects アプリケーションを動かすことができる、と Practical WebObjects の 10 章に書いてあるので、 きっとできるんでしょう。

それ以外にもこの本はかなり実践的で役に立つことがいっぱい書かれてますので、中/上級者をめざす人は必読です。

Practical WebObjectsPractical WebObjects

Practical WebObjects のソースコードは apress のサイト からダウンロードできます。

コメント(2) [コメントを投稿する]
_ にわかSUSEr 2004/08/24-15:30:35

apache 用アダプタをmakeする前の環境変数 OS の設定部分
× # export OS=linux
○ # export OS=LINUX
でお願いします・・・。

_ tmaeda 2004/08/24-21:03:02

にわかSUSEr さん、ご指摘ありがとうございましたm(__)m
おっしゃる通りです。直しておきました。
今後も何かありましたらご指摘よろしくお願い致します。


編集