# cd /usr/local/src
# wget http://apache.tt.co.kr/tomcat/tomcat-6/v6.0.36/bin/apache-tomcat-6.0.36.tar.gz
# tar zxvf apache-tomcat-6.0.36.tar.gz
# cp -Rf apache-tomcat-6.0.36 /usr/local/tomcat
# cd ../tomcat/
# ll
Total 144
-rw-r--r-- 1 root root 37951 11?? 15 16:42 LICENSE
-rw-r--r-- 1 root root 558 11?? 15 16:42 NOTICE
-rw-r--r-- 1 root root 9188 11?? 15 16:42 RELEASE-NOTES
-rw-r--r-- 1 root root 15576 11?? 15 16:42 RUNNING.txt
drwxr-xr-x 2 root root 4096 11?? 15 16:42 bin
drwxr-xr-x 2 root root 4096 11?? 15 16:42 conf
drwxr-xr-x 2 root root 4096 11?? 15 16:42 lib
drwxr-xr-x 2 root root 4096 11?? 15 16:42 logs
drwxr-xr-x 2 root root 4096 11?? 15 16:42 temp
drwxr-xr-x 7 root root 4096 11?? 15 16:42 webapps
drwxr-xr-x 2 root root 4096 11?? 15 16:42 work
GET을 통해 한글데이터를 받을 때 서버에서 URL을 UTF-8로 인코딩하도록 설정 (URIEncoding="UTF-8")
# vi conf/server.xml
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
maxThreads="150"
minSpareThreads="25"
maxSpareThreads="75"
enableLookups="false"
acceptCount="100"
disableUploadTimeout="true"
URIEncoding="UTF-8" />
디렉토리 리스팅 막기 (listing false)
# vi conf/web.xml
<servlet-name>default</servlet-name>
<servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
CATALINA_HOME 설정
# vi /etc/profile
JAVA_HOME=/usr/java/jdk1.6.0_37
export JAVA_HOME
CATALINA_HOME=/usr/local/tomcat
export CATALINA_HOME
PATH=$PATH:$JAVA_HOME/bin:$CATALINA_HOME/bin
export PATH
CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$CATALINA_HOME/lib
export CLASSPATH
# source /etc/profile
컨텍스트를 생성하자
# mkdir -p ./conf/Catalina/localhost
# mkdir -p /abcd/webapp
# vi ./conf/Catalina/localhost/abcd.xml
<Context path="/tone" docBase="/tone/webapp">
<Resource name="jdbc/abcd"
auth="Container"
type="javax.sql.DataSource"
factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://192.168.0.206:3306/abcd"
username="abcd"
password="abcd"
testWhileIdle="true"
testOnBorrow="true"
testOnReturn="false"
validationQuery="SELECT 1"
validationInterval="30000"
timeBetweenEvictionRunsMillis="30000"
maxActive="100"
minIdle="10"
maxWait="10000"
initialSize="10"
removeAbandonedTimeout="60"
removeAbandoned="true"
logAbandoned="true"
minEvictableIdleTimeMillis="30000"
jmxEnabled="true"/>
</Context>
mysql을 사용하므로 mysql-connector-java를 다운받아 tomcat lib 폴더에 넣어준다.
# cd /usr/local/src
# wget http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.22.tar.gz/from/http://cdn.mysql.com/
# tar xzvf mysql-connector-java-5.1.22.tar.gz
# cd mysql-connector-java-5.1.22
# cp mysql-connector-java-5.1.22-bin.jar /usr/local/tomcat/lib/
톰캣 실행
# startup.sh
종료는
# shutdown.sh