Application/Web

리눅스 아파치 톰캣 연동

realforce111 2016. 5. 25. 11:23

https://tomcat.apache.org 사이트에 접속하여 Tomcat Connectors 파일 다운로드 주소를 복사합니다.


[root@localhost ~]# cd /usr/local/src

[root@localhost src]# wget https://downloads.apache.org/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.48-src.tar.gz -O connector.tar.gz

wget 뒤에 복사한 다운로드 주소를 입력하여 Tomcat Connectors 파일을 다운로드합니다.


[root@localhost src]# tar -zxvf connector.tar.gz

[root@localhost src]# cd tomcat-connectors-1.2.48-src/native/

[root@localhost native]# ./configure --with-apxs=/usr/local/apache/bin/apxs

[root@localhost native]# make && make install

파일을 압축 해제하고 컴파일을 진행합니다.


[root@localhost native]# cd /usr/local/apache/conf

[root@localhost conf]# vi workers.properties

worker.list=ajp13 

worker.ajp13.port=8009 

worker.ajp13.host=localhost 

worker.ajp13.type=ajp13

workers.properties 파일 생성


[root@localhost conf]# vi mod_jk.conf

<IfModule mod_jk.c> 

JkWorkersFile "/usr/local/apache/conf/workers.properties" 

JkLogFile "/usr/local/src/tomcat9/logs/mod_jk.log" 

JkLogLevel info 

JkAutoAlias "/usr/local/src/tomcat9/webapps" 

JkMount /* ajp13 

JkMount /*.jsp ajp13 

JkMount /servlet/* ajp13 

JkMount /examples/*.jsp ajp13 

JkLogStampFormat "[%a %b %d %H:%M:%S %Y]" 

JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories 

JkRequestLogFormat "%w %V %T" 

</IfModule>

mod_jk.conf 파일 생성


[root@localhost conf]# vi httpd.conf


LoadModule unixd_module modules/mod_unixd.so

#LoadModule dav_module modules/mod_dav.so

LoadModule status_module modules/mod_status.so

LoadModule autoindex_module modules/mod_autoindex.so

#LoadModule info_module modules/mod_info.so

#LoadModule cgid_module modules/mod_cgid.so

#LoadModule dav_fs_module modules/mod_dav_fs.so

#LoadModule vhost_alias_module modules/mod_vhost_alias.so

#LoadModule negotiation_module modules/mod_negotiation.so

LoadModule dir_module modules/mod_dir.so

#LoadModule actions_module modules/mod_actions.so

#LoadModule speling_module modules/mod_speling.so

#LoadModule userdir_module modules/mod_userdir.so

LoadModule alias_module modules/mod_alias.so

#LoadModule rewrite_module modules/mod_rewrite.so

#152번째 줄에 LoadModule 설정 추가

LoadModule jk_module modules/mod_jk.so


<IfModule unixd_module>

#

# If you wish httpd to run as a different user or group, you must run

# httpd as root initially and it will switch.

#

# User/Group: The name (or #number) of the user/group to run httpd as.

# It is usually good practice to create a dedicated user and group for

# running httpd, as with most system services.

#

User daemon

Group daemon

~

# Configure mod_proxy_html to understand HTML4/XHTML1

<IfModule proxy_html_module>

Include conf/extra/proxy-html.conf

</IfModule>


# Secure (SSL/TLS) connections

#Include conf/extra/httpd-ssl.conf

#

# Note: The following must must be present to support

#       starting without SSL on platforms with no /dev/random equivalent

#       but a statically compiled-in mod_ssl.

#

<IfModule ssl_module>

SSLRandomSeed startup builtin

SSLRandomSeed connect builtin

</IfModule>

#맨 마지막줄에 incloud 설정 추가

include conf/mod_jk.conf

httpd.conf 파일을 수정합니다. 152번째 줄에 LoadModule 설정을 추가하고 맨 마지막 줄에 incloud를 추가합니다.


[root@localhost conf]# cd /usr/local/src/tomcat9/conf/

[root@localhost conf]# vi server.xml 

    <!-- Define an AJP 1.3 Connector on port 8009 -->

    #<!--, --> 주석 해제

    <Connector protocol="AJP/1.3"

               address="::1"

               secretRequired="false"

               port="8009"

               redirectPort="8443" />


    <!-- An Engine represents the entry point (within Catalina) that processes

         every request.  The Engine implementation for Tomcat stand alone

         analyzes the HTTP headers included with the request, and passes them

         on to the appropriate Host (virtual host).

         Documentation at /docs/config/engine.html -->

server.xml 파일을 수정합니다. AJP Connector 부분에 주석을 해제하고 secretRequired="false"를 추가합니다.


[root@localhost conf]# /usr/local/src/tomcat9/bin/startup.sh 

Using CATALINA_BASE:   /usr/local/src/tomcat9

Using CATALINA_HOME:   /usr/local/src/tomcat9

Using CATALINA_TMPDIR: /usr/local/src/tomcat9/temp

Using JRE_HOME:        /usr

Using CLASSPATH:       /usr/local/src/tomcat9/bin/bootstrap.jar:/usr/local/src/tomcat9/bin/tomcat-juli.jar

Using CATALINA_OPTS:   

Tomcat started.

[root@localhost conf]# systemctl restart apache

톰캣과 아파치 서비스를 시작합니다.


웹브라우저에서 http://<서버 IP>으로 접속해보면 연동이 정상적으로 완료되어 톰캣 페이지가 출력됩니다.