Apache とTomcat の連携
mod_proxy_ajp を組み込んで Tomcat と連携する設定
環境
apache-2.2.14 |
Solaris 10 5/09 x86 |
VMware Server 1.0.8 |
OS をインストールして入っていた apache のバージョンは 2.0 だったので ajp を使用するため 2.2 をソースからインストール
インストール
$ wget http://ftp.riken.jp/net/apache/httpd/httpd-2.2.14.tar.gz $ gzip -dc httpd-2.2.14.tar.gz | tar xvf - $ cd httpd-2.2.14 $ ./configure --enable-proxy --enable-proxy_ajp --enable-ssl=shared (実行したら以下のように openssl のヘッダファイルがないというエラー) ----途中省略---- checking for OpenSSL version... checking openssl/opensslv.h usability... no checking openssl/opensslv.h presence... no checking for openssl/opensslv.h... no checking openssl/ssl.h usability... no checking openssl/ssl.h presence... no checking for openssl/ssl.h... no no OpenSSL headers found checking for SSL-C version... checking sslc.h usability... no checking sslc.h presence... no checking for sslc.h... no no SSL-C headers found configure: error: ...No recognized SSL/TLS toolkit detected
openssl のヘッダファイルが /usr/sfw ディレクトリに存在したので -with-ssl=/usr/sfw を configure オプションに追加
$ ./configure --enable-proxy --enable-proxy_ajp \ --enable-ssl=shared -with-ssl=/usr/sfw Configuring Apache Portable Runtime Utility library... checking for APR-util... reconfig configure: error: Cannot use an external APR with the bundled APR-util
http://httpd.apache.org/docs/2.2/ja/install.html の「apr/apr-util >= 1.2」を参考に apr と apr-util を手動でインストール
# Build and install apr 1.2 $ cd srclib/apr $ ./configure --prefix=/usr/local/apr-httpd/ $ make $ sudo make install # Build and install apr-util 1.2 $ cd ../apr-util $ ./configure --prefix=/usr/local/apr-util-httpd/ \ --with-apr=/usr/local/apr-httpd/ $ make $ sudo make install
再度 configure を実行して成功
$ cd ../../ $ ./configure --enable-proxy --enable-proxy_ajp \ --enable-ssl=shared -with-ssl=/usr/sfw --with-apr=/usr/local/apr-httpd/ \ --with-apr-util=/usr/local/apr-util-httpd/ $ make
http.conf 設定
# vi /usr/local/apache2/conf/httpd.conf 以下の行を追加 Include conf/extra/httpd-tomcat.conf
extra/httpd-tomcat.conf を作成
<Location /> ProxyPass ajp://192.168.2.123:8009/ </Location>
apache の起動
# /usr/local/apache2/bin/apachectl start
サービスを SMF で管理できるようにするには method ファイルを/lib/svc/method ディレクトリに作成して
サービスデータベースに登録します。
ここでは OS をインストールして入っていた、既存の apache2.0 用の method ファイル(http-apache2)を修正することにします。
# cp /lib/svc/method/http-apache2 /lib/svc/method/http-apache2_org # vi /lib/svc/method/http-apache2 [変更前] APACHE_HOME=/usr/apache2 CONF_FILE=/etc/apache2/httpd.conf [変更後] APACHE_HOME=/usr/local/apache2 CONF_FILE=/usr/local/apache2/conf/httpd.conf
SMF でサービスを起動
# svcadm enable http