본문 바로가기

리눅스

CentOS 6.4 Linux + Apache + Apache Tomcat 연동_u1

반응형

CentOS 6.4 Linux + Apache + Apache Tomcat 연동

1. JDK(JAVA) 설치

cd /usr/local/src
./jdk-6u45-linux-i586-rpm.bin
vim /etc/profile
export JAVA_HOME=/usr/local/java
export PATH=$PATH:$JAVA_HOME/bin
alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_45/bin/java 2
alternatives --config java
/usr/bin/java –version

2. Apache 설치

cd httpd-2.2.25
./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite --enable-ssl --enable-proxy --with-mpm=worker --with-included-apr --enable-modules=all --enable-mods-shared=all
make && make install
vim /usr/local/apache2/conf/extra/httpd-vhosts.conf
<VirtualHost *:80>
    ServerAdmin admin@sangchul.kr
    DocumentRoot "/home/lamp.sangchul.kr/public_html"
    ServerName lamp.sangchul.kr
    ServerAlias www.lamp.sangchul.kr
    ErrorLog "/logs/lamp.sangchul.kr-error.log"
    CustomLog "/logs/lamp.sangchul.kr-access.log" common
</VirtualHost>
vim index.html
<html>
	<title>
		lamp.sangchul.kr
	</title>
	<body>
		<h1> lamp.sangchul.kr </h1>
	</body>
</html>

3. Tomcat 설치

tar xvfz apache-tomcat-6.0.37.tar.gz
mv apache-tomcat-6.0.37 /usr/local/tomcat
vim /etc/profile
export JAVA_HOME=/usr/local/java
export CATALINA_HOME=/usr/local/tomcat
export PATH=$PATH:$JAVA_HOME/bin:$CATALINA_HOME/bin
vim /usr/local/tomcat/conf/server.xml
128       <Host name="lamp.sangchul.kr"  appBase="webapps"
129             unpackWARs="true" autoDeploy="true"
130             xmlValidation="false" xmlNamespaceAware="false">
131       <Context path="" docBase="/home/lamp.sangchul.kr/public_html" debug="0" reloadable="true" />
728x90

 

vim /usr/local/tomcat/conf/web.xml
 126     <servlet>
 127         <servlet-name>invoker</servlet-name>
 128         <servlet-class>
 129           org.apache.catalina.servlets.InvokerServlet
 130         </servlet-class>
 131         <init-param>
 132             <param-name>debug</param-name>
 133             <param-value>0</param-value>
 134         </init-param>
 135         <load-on-startup>2</load-on-startup>
 136     </servlet>
...
 384     <servlet-mapping>
 385         <servlet-name>invoker</servlet-name>
 386         <url-pattern>/servlet/*</url-pattern>
 387     </servlet-mapping>
vim /usr/local/tomcat/conf/context.xml
19 <Context reloadable="true" privileged="true" >

4. tomcat-connectors tomcat + Apache 연동

cd tomcat-connectors-1.2.37-src/native
./buildconf.sh
./configure --with-apxs=/usr/local/apache2/bin/apxs --with-java-home=$JAVA_HOME
make && make install
vim /usr/local/apache2/conf/extra/workers.properties
  1 workers.tomcat_home=/usr/local/tomcat
  2 workers.java_home=/usr/local/java
  3 ps=/
  4 worker.list=ajp13
  5 worker.ajp13.type=ajp13
  6 worker.ajp13.host=locahost
  7 worker.ajp13.port=8009
  8 worker.ajp13.lbfactor=50
  9 worker.ajp13.cachesize=10
 10 worker.ajp13.cache_timeout=600
 11 worker.ajp13.socket_keepalive=1
 12 worker.ajp13.socket_timeout=300

5. 아파치 환경 설정

vim /usr/local/apache2/conf/httpd.conf
114 LoadModule jk_module modules/mod_jk.so
...
226 <IfModule dir_module>
227     DirectoryIndex index.html index.htm index.jsp
228 </IfModule>
...
467 <IfModule mod_jk.c>
468 JkWorkersFile conf/extra/workers.properties
469 JkLogFile /logs/mod_jk.log
470 jkShmFile /logs/jk.shm471 JkLogLevel error
472 JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
473 JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
474 JkRequestLogFormat "%w %V %T"
475 </IfModule>
vim /usr/local/apache2/conf/extra/httpd-vhosts.conf
27 <VirtualHost *:80>
28     ServerAdmin anti1346@nate.com
29     DocumentRoot "/home/lamp.sangchul.kr/public_html"
30     ServerName lamp.sangchul.kr
31     ServerAlias www.lamp.sangchul.kr
32     ErrorLog "/logs/lamp.sangchul.kr-error.log"
33     CustomLog "/logs/lamp.sangchul.kr-access.log" common
34
35     JkMount /* ajp13
36
37 </VirtualHost>

6. JSP 테스트 페이지

vim index.jsp
<%
String msg = "lamp.sangchul.kr JAVA PAGE";
%>
<%= msg %>

 

728x90
반응형