Ⅰ. JAVA JDK 설치
1. profile의 젤 아래부분에 환경설정.
# vi /etc/profile
---------------------------------------------------------------
# Setting for JDK
export JAVA_HOME=/usr/local/java/jdk
export CATALINA_HOME=/usr/local/tomcat
export PATH=$JAVA_HOME:$CATALINA_HOME:.:$PATH
export CLASSPATH=$JAVA_HOME/lib/tools.jar:
$CATALINA_HOME/lib/servlet-api.jar:
$CATALINA_HOME/lib/jsp-api.jar:
$CATALINA_HOME/webapps/ROOT/WEB-INF/classes
---------------------------------------------------------------
# source /etc/profile <-- 바로적용
2. JDK 다운로드 한다음 임의의 디렉토리에 저장.
http://java.sun.com/javaee/downloads/index.jsp
# ls
java_ee_sdk-5_01-linux.bin
# mkdir /usr/local/java
# ./jdk-1_5_0_07-linux-i586.bin
설치가 시작되면서 진행중 약관동의 승인과 압축을 풀 디렉토리 지정을 물어 본다.
설치 경로를 /usr/local/java로 입력하고 설치를 완료한다.
Ⅱ. Apache 설치
# wget http://mirror.apache.or.kr/httpd/httpd-2.2.3.tar.gz
--11:12:10-- http://mirror.apache.or.kr/httpd/httpd-2.2.3.tar.gz
=> `httpd-2.2.3.tar.gz'
Resolving mirror.apache.or.kr... 211.53.110.2
Connecting to mirror.apache.or.kr[211.53.110.2]:80... connected.
HTTP 요청을 보냅니다, 서버로부터의 응답을 기다림...200 OK
길이: 6,342,475 [application/x-gzip]
100%[==========================================================>] 6,342,475 960.11K/s ETA 00:00
11:12:16 (914.48 KB/s) - `httpd-2.2.3.tar.gz' saved [6,342,475/6,342,475]
# tar zxvf httpd-2.2.3.tar.gz
# cd httpd-2.2.3
# ./configure --prefix=/usr/local/apache --enable-modules=all --enable-mods-shared=all
# make
# make install
# cd /usr/local/apache/bin
# apachectl configtest
Syntax OK
# apachectl start
http://localhost => It works!
Ⅲ. Tomcat 설치
# wget http://ftp.apache-kr.org/tomcat/tomcat-6/v6.0.2/bin/apache-tomcat-6.0.2.tar.gz
--17:16:59-- http://ftp.apache-kr.org/tomcat/tomcat-6/v6.0.2/bin/apache-tomcat-6.0.2.tar.gz
=> `apache-tomcat-6.0.2.tar.gz'
Resolving ftp.apache-kr.org... 211.174.58.187
Connecting to ftp.apache-kr.org[211.174.58.187]:80... connected.
HTTP 요청을 보냅니다, 서버로부터의 응답을 기다림...200 OK
길이: 5,796,879 [application/x-gzip]
100%[========================================================================================>] 5,796,879 1.08M/s ETA 00:00
17:17:07 (735.93 KB/s) - `apache-tomcat-6.0.2.tar.gz' saved [5,796,879/5,796,879]
# tar zxvf apache-tomcat-6.0.2.tar.gz
# mv apache-tomcat-6.0.2 /usr/local
# cd /usr/local
# mv apache-tomcat-6.0.2 tomcat
# cd tomcat/bin
# startup.sh
## Linux IP table 수정부분참조
# iptables -L
# iptables -I RH-Firewall-1-INPUT 16 -m state --state NEW -p tcp --dport 4848 -j ACCEPT
# iptables -I RH-Firewall-1-INPUT 17 -m state --state NEW -p tcp --dport 8080 -j ACCEPT
# iptables -I RH-Firewall-1-INPUT 18 -m state --state NEW -p tcp --dport 8181 -j ACCEPT
http://localhost:8080 => 초기페이지
Ⅳ. Tomcat Connector2 설치
# wget http://ftp.apache-kr.org/tomcat/tomcat-connectors/jk2/jakarta-tomcat-connectors-jk2-src-current.tar.gz
--15:57:09-- http://ftp.apache-kr.org/tomcat/tomcat-connectors/jk2/jakarta-tomcat-connectors-jk2-src-current.tar.gz
=> `jakarta-tomcat-connectors-jk2-src-current.tar.gz'
Resolving ftp.apache-kr.org... 211.174.58.187
Connecting to ftp.apache-kr.org[211.174.58.187]:80... connected.
HTTP 요청을 보냅니다, 서버로부터의 응답을 기다림...200 OK
길이: 907,088 [application/x-gzip]
100%[========================================================================================>] 907,088 954.38K/s
15:57:10 (950.95 KB/s) - `jakarta-tomcat-connectors-jk2-src-current.tar.gz' saved [907,088/907,088]
# cp jakarta-tomcat-connectors-jk2-src-current.tar.gz /usr/local
# tar zxvf jakarta-tomcat-connectors-jk2-src-current.tar.gz
# cd jakarta-tomcat-connectors-jk2-2.0.4-src/
# cd jk/native2
# ./configure --with-apxs2=/usr/local/apache/bin/apxs
# make
# cd /usr/local/jakarta-tomcat-connectors-jk2-2.0.4-src/jk/build/jk2/apache2
# ls -al mod_jk2.so
# cp mod_jk2.so /usr/local/apache/modules
# ls -al /usr/local/apache/modules/mod_jk2.so
# cd /usr/local/jakarta-tomcat-connectors-jk2-2.0.4-src/jk/conf
# cp workers2.properties /usr/local/apache/conf
# cp jk2.properties /usr/local/tomcat/conf
# cd /usr/local/apache/conf
# vi workers2.properties
=======================================================================
# Shared memory handling. Needs to be set.
[shm]
file=/usr/local/apache/logs/jk2.shm
size=1048576
# Example socket channel, explicitly set port and host.
[channel.socket:localhost:8009]
port=8009
host=127.0.0.1
# define the worker
[ajp13:localhost:8009]
channel=channel.socket:localhost:8009
# Announce a "status" worker
[status:status]
# Uri mapping
[uri:/jsp-examples/*]
worker=ajp13:localhost:8009
[uri:/servlets-examples/*]
worker=ajp13:localhost:8009
[uri:/tomcat-docs/*]
worker=ajp13:localhost:8009
# jsp파일 연동처리
[uri:/*.jsp]
worker=ajp13:localhost:8009
# /usr/local/tomcat/webapps/ROOT/WEB-INF/web.xml파일에 servlet-mapping/url-pattern과 똑같이 해주면 된다.
# 그러면 servlet도 연동된다.
[uri:/servlet/*]
worker=ajp13:localhost:8009
[uri:/status/*]
worker=status:status
=======================================================================
# iptables -I RH-Firewall-1-INPUT 19 -m state --state NEW -p tcp --dport 8009 -j ACCEPT
# vi /usr/local/apache/conf/httpd.conf
DirectoryIndex index.html index.jsp
LoadModule jk2_module modules/mod_jk2.so
DocumentRoot "/usr/local/apache2/htdocs" => DocumentRoot "/usr/local/tomcat/webapps/ROOT"
<Directory "/usr/local/apache2/htdocs"> => <Directory "/usr/local/tomcat/webapps/ROOT">
# vi /usr/local/tomcat/conf/jk2.properties
==================================================================================
## THIS FILE MAY BE OVERRIDEN AT RUNTIME. MAKE SURE TOMCAT IS STOPED
## WHEN YOU EDIT THE FILE.
## COMMENTS WILL BE _LOST_
## DOCUMENTATION OF THE FORMAT IN JkMain javadoc.
# Set the desired handler list
# handler.list=apr,request,channelJni
#
# Override the default port for the socketChannel
# channelSocket.port=8019
channelSocket.port=8009
# Default:
# channelUnix.file=${jkHome}/work/jk2.socket
# Just to check if the the config is working
# shm.file=${jkHome}/work/jk2.shm
shm.file=/usr/local/apache/logs/jk2.shm
# In order to enable jni use any channelJni directive
# channelJni.disabled = 0
# And one of the following directives:
# apr.jniModeSo=/opt/apache2/modules/mod_jk2.so
# If set to inprocess the mod_jk2 will Register natives itself
# This will enable the starting of the Tomcat from mod_jk2
apr.jniModeSo=inprocess
==================================================================================
# cd /usr/local/apache/bin
# apachectl restart
# cd /usr/local/tomcat/bin
# shutdown.sh
# startup.sh
* virtualHost로 설정한 예(parklab.net, cic.kdtc.kr)
----------------------------------------------------------------------------------
# vi /usr/local/apache/conf/httpd.conf
DocumentRoot "/usr/local/tomcat/webapps"
<Directory "/usr/local/tomcat/webapps">
# vi /usr/local/apache/conf/extra/httpd-vhosts.conf
NameVirtualHost 203.246.74.196
<VirtualHost linux.parklab.net>
ServerAdmin webmaster@linux.parklab.net
DocumentRoot /usr/local/tomcat/webapps/linux.parklab.net
ServerName linux.parklab.net
ServerAlias linux.parklab.net
ErrorLog logs/linux.parklab.net-error_log
CustomLog logs/linux.parklab.net-access_log common
</VirtualHost>
<VirtualHost cic.kdtc.kr>
ServerAdmin webmaster@linux.parklab.net
DocumentRoot /usr/local/tomcat/webapps/cic.kdtc.kr
ServerName cic.kdtc.kr
ServerAlias cic.kdtc.kr
ErrorLog logs/cic.kdtc.kr-error_log
CustomLog logs/cic.kdtc.kr-access_log common
</VirtualHost>
# vi /usr/local/tomcat/conf/server.xml
<Host name="linux.parklab.net" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.valves.FastCommonAccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
-->
<Context
path=""
docBase="/usr/local/tomcat/webapps/linux.parklab.net"
debug="0"
reloadable="true"
crossContext="true">
</Context>
<Alias>linux.parklab.net</Alias>
<Logger
className="org.apache.catalina.logger.FileLogger"
directory="/usr/local/tomcat/webapps/linux.parklab.net/logs"
prefix="linux.parklab.net_log."
suffix=".txt"
timestamp="true"/>
</Host>
<Host name="cic.kdtc.kr" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.valves.FastCommonAccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
-->
<Context
path=""
docBase="/usr/local/tomcat/webapps/cic.kdtc.kr"
debug="0"
reloadable="true"
crossContext="true">
</Context>
<Alias>cic.kdtc.kr</Alias>
<Logger
className="org.apache.catalina.logger.FileLogger"
directory="/usr/local/tomcat/webapps/cic.kdtc.kr/logs"
prefix="cic.kdtc.kr_log."
suffix=".txt"
timestamp="true"/>
</Host>
# vi /usr/local/tomcat/webapps/linux.parklab.net/WEB-INF/web.xml
<?xml version="1.0" encoding="euc-kr"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<display-name>linux.parklab.net</display-name>
<description>
linux.parklab.net HomePage.....
</description>
<servlet>
<servlet-name>HelloServlet</servlet-name>
<servlet-class>HelloServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
# vi /usr/local/tomcat/webapps/cic.kdtc.kr/WEB-INF/web.xml
도...마찬가지로...설정하면 된다.
# adduser dev
# passwd dev
# vi /etc/passwd
dev:x:502:503::/usr/local/tomcat/webapps/linux.parklab.net:/bin/bash
# chown -R dev:dev /usr/local/tomcat/webapps/linux.parklab.net