コネクタにはいくつか種類があります. Apache バージョン 2.0 以前では、Jk, Jk2 コネクタが有名でした。この Web ページでインストール手順を説明する. Apache Tomcat コネクタとしては,Jk コネクタ あるいは Jk2 コネクタの、どちらか片方を選んでインストールしてください.
Jk コネクタは,Apache HTTP サーバのモジュール (mod_jk) になっています.
インストールの前に,Apache Tomcat がインストール済みであること.
cd /tmp tar -xvzof tomcat-connectors-1.2.21-src.tar.gz cd native ./configure make make install
LoadModule jk_module modules/mod_jk.so JkWorkersFile /etc/httpd/conf.d/workers.properties JkLogFile /var/log/httpd/mod_jk.log JkLogLevel info JkLogStampFormat "[%a %b %d %H:%M:%S %Y] " JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories JkRequestLogFormat "%w %V %T" JkMount /servlets-examples/* ajp13 JkMount /jsp-examples/* ajp13
workers.tomcat_home=/usr/local/apache-tomcat-5.5.23 workers.java_home=/usr/local/j2sdk1.6.0 # You should configure your environment slash... ps=\ on NT and / on UNIX # and maybe something different elsewhere. ps=/ worker.list=ajp13 worker.ajp13.port=8009 worker.ajp13.host=localhost worker.ajp13.type=ajp13
/usr/local/apachet2/bin/apachectl -k graceful
Tomcat の conf ディレクトリ (C:\tomcat55\conf) にある server.xml を編集.
port="8080"についての設定を、次のように書き換える。
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector" port="8080" minProcessors="5" maxProcessors="75" address="127.0.0.1" enableLookups="true" redirectPort="8443" acceptCount="100" debug="0" connectionTimeout="20000" useURIValidationHack="false" disableUploadTimeout="true" />
port="8009"についての設定を、次のように書き換える。
<!-- Define an AJP 1.3 Connector on port 8009 --> <Connector port="8009" address="127.0.0.1" enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />
以下,Windows で Jk2 コネクタをインストールする手順を示している. このコネクタは,Apache HTTP サーバのモジュール (mod_jk2) になっています.
なお,Jk2 コネクタは,実はすでにメンテナンスが終了している. Jk コネクタの使用が推奨されている.
インストールの前に,Apache Tomcat がインストール済みであること.
https://jakarta.apache.org/site/downloads/index.html
conf, doc, modules の3つのフォルダができる. 上記3つのフォルダに対して下記の 3, 4, 5 の手順を行う.
conf\workers2.properties.sample を、apache の conf フォルダ (c:\Program Files\Apache Group\Apache2\conf) に workers2.propertiesという名前でコピー(ファイル名の変更)する.その後,workers2.properties の内容を変更する.
[変更前] [uri:/examples/*] [変更後] [uri:/servlets-examples/*]
[変更前] JkSet config.file /usr/local/etc/apache2/workers2.properties [変更後] JkSet config.file conf/workers2.properties
LoadModule jk2_module modules/mod_jk2.so <IfModule mod_jk2.c> #----------------------------------------------- # Where to find the workers2.properties file #----------------------------------------------- # JkSet config.file conf/workers2.properties </IfModule>
付属の modules\mod_jk2.so を、apache の modules ディレクトリ (c:\Program Files\Apache Group\Apache2\modules) にコピー
doc ディレクトリの中身を,C:\tomcat55\docsのディレクトリにコピーする.
「channel Socket.port=8009」
Tomcat の conf ディレクトリ (C:\tomcat55\conf) にある server.xml を編集.
port="8080"についての設定を、次のように書き換える。
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector" port="8080" minProcessors="5" maxProcessors="75" address="127.0.0.1" enableLookups="true" redirectPort="8443" acceptCount="100" debug="0" connectionTimeout="20000" useURIValidationHack="false" disableUploadTimeout="true" />
port="8009"についての設定を、次のように書き換える。
<!-- Define an AJP 1.3 Connector on port 8009 --> <Connector port="8009" address="127.0.0.1" enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />
Tomcat に付属のサンプルファイルを使ってテスト
http://localhost/servlets-examples
今後、Tomcat の c:\tomcat55\webapps\cgi\WEB-INF\classes\ ディレクトリには、クラス名.java のファイルが多数置かれることになる。 http://localhost/cgi/クラス名という URL を使って、このクラスの doGet メソッドが起動されるという仕組みになっている。