ubuntu에서 tomcat설치/apache2에 연동
http://cafe.naver.com/czar/39
* /etc/bash.bashrc의 마지막에 다음 두 줄 추가. (Java가 /usr/java에 미리 설치된 것으로 가정한다.)
인용:
export JAVA_HOME=/usr/java
export TOMCAT_HOME=/usr/tomcat
* tomcat을 다운 받아 압축을 푼후, 다음과 같이 설치한다. (경우에 따라 버전이 다른 tomcat을 설치하는 경우가 있어, 이 방법을 선호한다.)
인용:
sudo mv jakarta-tomcat-5.5.9 /usr/local/tomcat/
sudo chown -R root:root /usr/local/tomcat/jakarta-tomcat-5.5.9/
sudo ln -s /usr/local/tomcat/jakarta-tomcat-5.5.9 /usr/tomcat
* tomcat의 8080 port를 다른 port로 변경해야 할 때는 /usr/tomcat/conf/server.xml 을 변경을 한다. (mono-xsp가 8080을 쓰고 있기에 tomcat을 9090으로 변경하였다.)
* 다음과 같이 tomcat 설치가 제대로 되었는지 확인해 본다.
인용:
sudo /usr/tomcat/bin/startup.sh
브라우저에서, http://localhost:9090
* 설치한 tomcat을 apache2와 연동하기 위해 jk2를 설치한다. (배포판에서 기본 제공하는 것을 설치하였다.)
인용:
sudo apt-get install libapache2-mod-jk2
* 다음의 파일들을 아래의 예처럼 각자의 경우에 맞게 적절히 수정한다.
인용:
/etc/apache2/mods-available/jk2.conf
JkSet config.file /usr/tomcat/conf/myWorkers2.properties
인용:
/usr/tomcat/conf/myWorkers2.properties
[logger]
level=DEBUG
[config:]
file=${serverRoot}/conf/myWorkers2.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
[channel.socket:localhost:8009]
info=Ajp13 forwarding over socket
debug=0
tomcatId=localhost:8009
[status:]
info=Status worker, displays runtime informations
[uri:/jkstatus/*]
info=Display status information and checks the config file for changes.
group=status:
[uri:/admin/*]
info=Tomcat HTML based administration web application.
debug=0
[uri:/manager/*]
info=A scriptable management web application for the Tomcat Web Server.
debug=0
[uri:/jsp-examples/*]
info=JSP 2.0 Examples.
debug=0
[uri:/servlets-examples/*]
info=Servlet 2.4 Examples.
debug=0
[uri:/*.jsp]
info=JSP Extension mapping.
debug=0
* jk2가 제대로 동작하는지를 확인하기 위해, apache를 재 시작하고, 브라우저에서 jkstatus를 본다.
인용:
sudo /etc/init.d/apache2 restart
http://localhost/jkstatus
* http://localhost/jsp-examples 하면, tomcat에서 제공하는 jsp 예제를 볼 수 있다 (왜냐면, uri를 myWorkers2.properties에 그렇게 정의했기 때문이다.)
mod_jk2 Deprecated
True!!!
jk-1.2를 사용해서 연동을 하려면,
1. 우선은 sudo apt-get remove libapache2-mod-jk2 해서 설치된 jk2를 삭제합니다.
2. http://www.apache.org/dist/jakarta/tomcat-connectors/jk/binaries/linux/ 에서 최신의 jk-1.2 버전을 다운 받습니다.
3. sudo cp jakarta-tomcat-connectors-jk-1.2.10-linux-sles9-i386-prefork.so /usr/lib/apache2/modules/mod_jk.so
4. /etc/apache2/mods-available/mod_jk.conf
인용:
# Load mod_jk module
# Specify the filename of the mod_jk lib
LoadModule jk_module /usr/lib/apache2/modules/mod_jk.so
# Where to find workers.properties
JkWorkersFile /usr/tomcat/conf/myWorkers.properties
# Where to put jk logs
JkLogFile /usr/tomcat/logs/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
# JkOptions indicates to send SSK KEY SIZE
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat
JkRequestLogFormat "%w %V %T"
# Mount your applications
#JkMount /application/* loadbalancer
# You can use external file for mount points.
# It will be checked for updates each 60 seconds.
# The format of the file is: /url=worker
# /examples/*=loadbalancer
jkMountFile /usr/tomcat/conf/myUriWorkerMap.properties
# Add shared memory.
# This directive is present with 1.2.10 and
# later versions of mod_jk, and is needed for
# for load balancing to work properly
JkShmFile /usr/tomcat/logs/jk.shm
# Add jkstatus for managing runtime data
<Location /jkstatus>
JkMount status
Order deny,allow
Deny from all
Allow from 127.0.0.1
# Allow from 999.999.999.999, your IP if you want
</Location>
5. sudo ln -s /etc/apache2/mods-available/mod_jk.conf /etc/apache2/mods-enabled/mod_jk.conf
다음의 예는 loadbalancer worker와 status worker를 정의해서 전자는 example들을 보는데 사용하고, 후자는 jkstatus를 보는데 사용하는 것입니다.
6. /usr/tomcat/conf/myWorkers.properties
인용:
# Define list of workers that will be used
# for mapping requests
worker.list=loadbalancer,status
# (1) local_worker should be commented out
# to enable load-balancing. Otherwise, only fail-over is available.
# Define Node1
worker.node1.port=8009
worker.node1.host=your IP or apache2 URL
worker.node1.type=ajp13
worker.node1.lbfactor=1
#worker.node1.local_worker=1 (1)
worker.node1.cachesize=10
# Define Node2
worker.node2.port=8009
worker.node2.host= your IP or apache2 URL
worker.node2.type=ajp13
worker.node2.lbfactor=1
#worker.node2.local_worker=1 (1)
worker.node2.cachesize=10
# Load-balancing behaviour
worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=node1, node2
worker.loadbalancer.sticky_session=1
worker.loadbalancer.local_worker_only=1
# Status worker for managing load balancer
worker.status.type=status
7. /usr/tomcat/conf/myUriWorkerMap.properties
인용:
# uriworkermap.properties - IIS
#
# This file provides sample mappings for example ajp13w
# worker defined in workermap.properties.minimal
# The general sytax for this file is:
# [URL]=[Worker name]
/jkstatus*=status
/servlets-examples/*=loadbalancer
/jsp-examples/*=loadbalancer
# 내 어플을 정의하려면, 여기에...
#/myApp/*=loadbalancer
# Optionally filter out all .jpeg files inside that context
# For no mapping the url has to start with exclamation (!)
#!/servlets-examples/*.jpeg=loadbalancer
'Computer Science' 카테고리의 다른 글
Hello, World! Web App (0) | 2009.04.23 |
---|---|
tomcat 세팅 및 가상 디렉토리 설정 하기 (0) | 2009.04.23 |
[FTP] Active Mode 와 Passive Mode (0) | 2009.04.23 |
홈페이지를 만들때 알아두면 유용한 무료사이트 정보 (0) | 2009.04.22 |
ubuntu 7.10에 Resin 설치 (0) | 2009.04.22 |