Set up tomcat at CentOS with Apache

Tomcat Download & Install

at first, download tomcat refer this site, http://tomcat.apache.org/download-70.cgi.

# wget http://apache.mirror.cdnetworks.com/tomcat/tomcat-7/v7.0.37/bin/apache-tomcat-7.0.37.tar.gz
# tar xvfz apache-tomcat-7.0.37.tar.gz
# mv apache-tomcat-7.0.37 /usr/local/tomcat

and make ‘init.d/tomcat’ file

#vi /etc/rc.d/init.d/tomcat

insert below.

#!/bin/bash
# description: Tomcat Start Stop Restart
# processname: tomcat
# chkconfig: 234 20 80

export JAVA_HOME=/usr/java/jdk1.6.0_35
export PATH=$JAVA_HOME/bin:$PATH
export CATALINA_HOME=/usr/local/tomcat

case $1 in
start)
sh $CATALINA_HOME/bin/startup.sh
;;
stop)
sh $CATALINA_HOME/bin/shutdown.sh
;;
restart)
sh $CATALINA_HOME/bin/shutdown.sh
sh $CATALINA_HOME/bin/startup.sh
;;
esac
exit 0
# chkconfig --add tomcat
# chkconfig --level 234 tomcat on

and check correctly

# chkconfig --list tomcat

Install mod_jk

refer this link http://tomcat.apache.org/download-connectors.cgi

# wget http://mod_jk_url
# tar xvfz apache-connectors.tar.gz

move to ‘/native’ at mod_jk folder.

# cd apache-connectors/native

start ‘buildconf.sh’  and install mod_jk

# ./buildconf.sh
# ./configure --with-apxs=/usr/local/apache/bin/apxs
# make
# make install

‘/usr/local/apache/bin/apxs’ can depending on the installation environment.

# find / -name apxs

if you don’t find ‘apxs’ ,

# yum install httpd-devel

Setting

make ‘workers.properties’ file at Apache’s conf folder.

# vi /usr/local/apache/conf/workers.properties

and insert this.

rker.list=ajp13
worker.ajp13.type=ajp13
worker.ajp13.host=localhost
worker.ajp13.port=8009
worker.ajp13.lbfactor=1
worker.ajp13.connection_pool_timeout=600
worker.ajp13.socket_keepalive=1

and edit ‘httpd.conf’

# vi /usr/local/apache/conf/httpd.conf
LoadModule    jk_module  modules/mod_jk.so
<ifModule jk_module>
  JkWorkersFile /usr/local/apache_2.2.21/conf/worker.properties
  JkShmFile /usr/local/apache_2.2.21/logs/mod_jk.shm
  JkLogFile /usr/local/apache_2.2.21/logs/mod_jk.log
  JkLogLevel error
  JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
  JkRequestLogFormat "%w %V %T"
</ifModule>

jkMount /*.jsp ajp13

<Directory />
  Options FollowSymLinks
  AllowOverride None
</Directory>

this can be different from where you installing.

Restart Tomcat and Apache

# /etc/rc.d/init.d/tomcat restart
# /etc/rc.d/init.d/httpd restart

Setting Virtual Host

vi /usr/local/tomcat/conf/server.xml

Insert below

<Host name="proinlab.com"  appBase="/home/proin/www"
    unpackWARs="true" autoDeploy="true"
    xmlValidation="false" xmlNamespaceAware="false">
    <Context path="" docBase="" debug="1" reloadable="true"/>
</Host>
# /etc/rc.d/init.d/tomcat restart

Test Page : http://proinlab.com:8080/jsp/test.jsp

댓글 남기기