ApacheとGlassFishをmod_jkというApacheのモジュールを使って連携する手順です。
インストール手順
1.mod_jkをダウンロードします。
公式サイトより
http://tomcat.apache.org/connectors-doc/
wgetで直接ダウンロード
wget http://www.apache.org/dist/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.37-src.tar.gz
2.ダウンロードしたmod_jkを解凍します。
tar xvzf tomcat-connectors-1.2.37-src.tar.gz
3.解凍したmod_jkにある「buildconf.sh」を実行します。
./native/buildconf.sh buildconf: checking installation... buildconf: autoconf version 2.63 (ok) buildconf: libtool version 2.2.6 (ok) buildconf: libtoolize --automake --copy buildconf: aclocal buildconf: autoheader buildconf: automake -a --foreign --copy buildconf: autoconf
4.configureを実行します。
with-apxsはapxsのある場所を指定します。
./native/configure --with-apxs=/usr/sbin/apxs
5.makeを実行します。
./native/make
6.makeでコンパイルすると「mod_jk.so」ができるのでApacheのモジュールディレクトリにコピーします。
cp ./native/apache-2.0/mod_jk.so /etc/httpd/modules
7.httpd.confにmod_jk.soを読み込む設定を追加します。
vi /etc/httpd/conf/httpd.conf
# httpd.conf
LoadModule jk_module modules/mod_jk.so
8.mod_jkのworker.propertiesを作成します。
vi /etc/httpd/conf.d/workers.properties # workers.properties worker.list=worker1 worker.worker1.type=ajp13 worker.worker1.host=127.0.0.1 worker.worker1.port=8009
9.mod_jk.confを作成します。
vi /etc/httpd/conf.d/mod_jk.conf # mod_jk.conf <IfModule mod_jk.c> JkWorkersFile /etc/httpd/conf.d/workers.properties JkMount /jenkins* worker1 # glassfish側のアプリパスを指定する ここではjenkinsがGlassFish上にある場合 </Ifmodule>
10.GlassFishでリスナーを新規で登録します。
新規で登録するリスナーのを指定します。ここでは「mod-jk-listener」とつけます。
./glassfish3/bin/asadmin asadmin> create-http-listener --listenerport 8009 --listeneraddress 0.0.0.0 --defaultvs server mod-jk-listener 管理ユーザー名を入力してください> admin ユーザー"admin"の管理パスワードを入力してください> コマンドcreate-http-listenerは正常に実行されました。
11.GlassFishでmod_jkを有効にします。
10のリスナー登録の続きでasadminコマンド内でコマンドを実行します。
asadmin> set server-config.network-config.network-listeners.network-listener.mod-jk-listener.jk-enabled=true 管理ユーザー名を入力してください> admin ユーザー"admin"の管理パスワードを入力してください> server-config.network-config.network-listeners.network-listener.mod-jk-listener.jk-enabled=true コマンドsetは正常に実行されました。
12.GlassFishを再起動します。
# GlassFishのコマンドから再起動 ./glassfish3/bin/asadmin restart-domain # 自動起動スクリプトがあるならこちら service glassfish restart
以上で終了です。