カスタム検索
tomo.gif (1144 ツバツイツト)line.gif (927 ツバツイツト)line.gif (927 ツバツイツト)line.gif (927 ツバツイツト)To previous pageTo home pageMailing to me

Tomcat5.0+J2SE1.4の実験
(CentOS4.4)

Modified: 28 October 2006


ダウンロードからインストール (28 October 2006
Apache2.0との連携 (28 October 2006
自動起動の設定 (28 October 2006


 ダウンロードからインストール 

J2SEのダウンロードとインストール

以下からダウンロードします。

http://java.sun.com/j2se/1.4.2/ja/download.html

"j2sdk-1_4_2_12-linux-i586-rpm.bin"がダウンロードできました。

以下のように解凍してインストールします。

# ./j2sdk-1_4_2_12-linux-i586-rpm.bin
# rpm -ivh j2sdk-1_4_2_12-linux-i586.rpm 
Preparing...                ########################################### [100%]
   1:j2sdk                  ########################################### [100%]
# 


Tomcat5のダウンロードとインストール

以下から、Tomcat5.0 をダウンロードします。

http://tomcat.apache.org/download-55.cgi

以下のように解凍し、Webサイトの領域に移動(コピー)します。

# tar zxvf jakarta-tomcat-5.0.28.tar.gz
        :
# mv jakarta-tomcat-5.0.28 /var/www/html

# ln -s /var/www/html/jakarta-tomcat-5.0.28 tomcat5


Tomcatの起動

起動の前に以下の環境変数を設定します。

# export JAVA_HOME=/usr/java/j2sdk1.4.2_12/
# export CATALINA_BASE=/var/www/html/tomcat5

以下のコマンドで起動します。

# $CATALINA_BASE/bin/startup.sh
Using CATALINA_BASE:   /var/www/html/tomcat5
Using CATALINA_HOME:   /var/www/html/tomcat5
Using CATALINA_TMPDIR: /var/www/html/tomcat5/temp
Using JAVA_HOME:       /usr/java/j2sdk1.4.2_12/
# 


動作確認

ポート8080を指定して開いてみます。

http://192.168.0.33:8080/


 Apache2.0との連携 

ApacheとTomcatの連携方法は、以下に解説されています。
http://www.wings.msn.to/index.php/-/B-08/jsp_win_connector/


"mod_jk2"のダウンロード

http://archive.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/linux/jk-1.2.19/

上記からソースをダウンロードし、以下の手順で、インストールします。 

# ./configure --with-apxs2=/usr/sbin/apxs
# make
# cp ../build/jk2/apache2/mod_jk2.so /etc/httpd/modules/
# cp ../conf/workers2.properties /etc/httpd/conf


"
mod_jk2.conf"の設定

"/etc/httpd/conf.d/mod_jk2.conf"を設定します。

LoadModule    jk2_module  modules/mod_jk2.so


"
workers2.properties"の設定

"/etc/httpd/conf/workers2.properties"に、サンプルが実行できるように追加設定します。

[logger]
level=DEBUG

[config:]
file=${serverRoot}/conf/workers2.properties
debug=0
debugEnv=0

[uriMap:]
info=Maps the requests. Options: debug
debug=0

# Alternate file logger
#[logger.file:0]
#level=DEBUG
#file=${serverRoot}/logs/jk2.log

[shm:]
info=Scoreboard. Required for reconfiguration and status with multiprocess servers
file=${serverRoot}/logs/jk2.shm
size=1000000
debug=0
disabled=0

[workerEnv:]
info=Global server options
timing=1
debug=0
# Default Native Logger (apache2 or win32 ) 
# can be overriden to a file logger, useful 
# when tracing win32 related issues
#logger=logger.file:0

[lb:lb]
info=Default load balancer.
debug=0

[lb:lb_1]
info=A second load balancer.
debug=0

[channel.socket:localhost:8009]
info=Ajp13 forwarding over socket
debug=0
tomcatId=localhost:8009

[channel.socket:localhost:8019]
info=A second tomcat instance. 
debug=0
tomcatId=localhost:8019
lb_factor=1
group=lb
group=lb_1
disabled=0

[channel.un:/opt/33/work/jk2.socket]
info=A second channel connecting to localhost:8019 via unix socket
tomcatId=localhost:8019
lb_factor=1
debug=0

[channel.jni:jni]
info=The jni channel, used if tomcat is started inprocess

[status:]
info=Status worker, displays runtime informations

[vm:]
info=Parameters used to load a JVM in the server process
#JVM=C:\jdk\jre\bin\hotspot\jvm.dll
classpath=${TOMCAT_HOME}/bin/tomcat-jni.jar
classpath=${TOMCAT_HOME}/server/lib/commons-logging.jar
OPT=-Dtomcat.home=${TOMCAT_HOME}
OPT=-Dcatalina.home=${TOMCAT_HOME}
OPT=-Xmx128M
#OPT=-Djava.compiler=NONE
disabled=1

[worker.jni:onStartup]
info=Command to be executed by the VM on startup. This one will start tomcat.
class=org/apache/jk/apr/TomcatStarter
ARG=start
# For Tomcat 5 use the 'stard' for startup argument
# ARG=stard
disabled=1
stdout=${serverRoot}/logs/stdout.log
stderr=${serverRoot}/logs/stderr.log

[worker.jni:onShutdown]
info=Command to be executed by the VM on shutdown. This one will stop tomcat.
class=org/apache/jk/apr/TomcatStarter
ARG=stop
disabled=1

[uri:/jkstatus/*]
info=Display status information and checks the config file for changes.
group=status:

[uri:127.0.0.1:8003]
info=Example virtual host. Make sure myVirtualHost is in /etc/hosts to test it
alias=myVirtualHost:8003

[uri:127.0.0.1:8003/ex]
info=Example webapp in the virtual host. It'll go to lb_1 ( i.e. localhost:8019 )
context=/ex
group=lb_1

[uri:/examples]
info=Example webapp in the default context. 
context=/examples
debug=0

[uri:/examples1/*]
info=A second webapp, this time going to the second tomcat only.
group=lb_1
debug=0

[uri:/examples/servlet/*]
info=Prefix mapping

[uri:/examples/*.jsp]
info=Extension mapping

[uri:/examples/*]
info=Map the whole webapp

[uri:/examples/servlet/HelloW]
info=Example with debug enabled.
debug=10

[uri:/servlets-examples/*]
[uri:/jsp-examples/*]


"
server.xml"の設定

"/var/www/html/tomcat5/conf/server.xml"を変更します。

以下が有効であるこを確認します。

                           :

    <!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->
    <Connector port="8009"
               enableLookups="false" redirectPort="8443" debug="0"
               protocol="AJP/1.3" />

                           :

直接、tomcatが実行されないように、以下を無効にします。

                           :
    <!-- Define a non-SSL Coyote HTTP/1.1 Connector on port 8080 -->
<!--
    <Connector port="8080"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               debug="0" connectionTimeout="20000"
               disableUploadTimeout="true" />
-->

                           :      


TOMCATを起動する

# /var/www/html/tomcat5/bin/startup.sh 
Using CATALINA_BASE:   /var/www/html/tomcat5
Using CATALINA_HOME:   /var/www/html/tomcat5
Using CATALINA_TMPDIR: /var/www/html/tomcat5/temp
Using JAVA_HOME:       /usr/java/j2sdk1.4.2_12/
# service httpd restart
httpd を停止中:                                            [  OK  ]
httpd を起動中:                                            [  OK  ]

# nmap localhost
Starting nmap 3.70 ( http://www.insecure.org/nmap/ ) at 2006-10-28 23:59 JST
Interesting ports on localhost (127.0.0.1):
(The 1654 ports scanned but not shown below are in state: closed)
PORT     STATE SERVICE
22/tcp   open  ssh
25/tcp   open  smtp
80/tcp   open  http
139/tcp  open  netbios-ssn
445/tcp  open  microsoft-ds
8009/tcp open  ajp13

Nmap run completed -- 1 IP address (1 host up) scanned in 3.698 seconds
# 


ポート8080を指定せず開いてみる

http://192.168.0.33/jsp-examples/jsp2/tagfiles/panel.jsp

ポートを指定せずに開けば、連携動作がうまくいっています。


 自動起動の設定 

"/etc/init.d/tomcat5"を作成

#!/bin/sh
# chkconfig: 345 98 20
# description: Watch system status
# processname: hotsanic

export JAVA_HOME=/usr/java/j2sdk1.4.2_12
export CATALINA_HOME=/var/www/tomcat55

exec $CATALINA_HOME/bin/catalina.sh $*

自動起動に設定

# chkconfig --add tomcat5
# chkconfig tomcat5 on

To previous pageTo home pageMailing to meJump to Top of pageline.gif (927 ツバツイツト)line.gif (927 ツバツイツト)tomo.gif (1144 ツバツイツト)
カスタム検索


Tweet