Notice
Recent Posts
Recent Comments
Link
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
Tags
more
Archives
Today
Total
관리 메뉴

Be an Overachiever

[Apache, Tomcat 연동] 3. Apache, Tomcat 1:1 연동 본문

서버/Apache

[Apache, Tomcat 연동] 3. Apache, Tomcat 1:1 연동

devson119 2018. 9. 20. 09:14

- 필수 패키지 설치
1
sudo yum -y install autoconf libtool
cs
 
- perl 스크립트 경로 변경
만약 /home/test/apache/bin/apxs 파일의 맨 윗줄이
#!/replace/with/path/to/perl/interpreter -w  경우
#!/usr/bin/perl -w  변경한다.

- mod_jk.so 설치
1
2
3
4
5
6
7
8
9
10
cd /home/test/install
wget http://mirror.navercorp.com/apache/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.44-src.tar.gz
tar zxvf tomcat-connectors-1.2.44-src.tar.gz
cd /home/test/install/tomcat-connectors-1.2.44-src/native
./buildconf.sh
./configure --with-apxs=/home/test/server/apache/bin/apxs
make
make install
libtool --finish /home/test/server/apache/modules
ls /home/test/server/apache/modules/mod_jk.so # mod_jk.so 확인
cs

 톰캣 AJP Connector 포트 확인 주석 풀기 (디폴트 8009) : Apache Tomcat 연결될 포트
1
vi /home/test/server/tomcat/apache-tomcat-8.5.34/conf/server.xml
cs


- Apache mod_jk 설정
1
vi /home/test/server/apache/conf/httpd.conf
cs
아래 하이라이트한 라인 추가
#
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l') do not need
# to be loaded here.
#
LoadModule jk_module modules/mod_jk.so

<IfModule jk_module>
        JkWorkersFile         conf/workers.properties
        JkLogFile             logs/mod_jk.log
        JkLogLevel            info
        JkMountFile           conf/url.properties
        JkLogStampFormat      "[%a %b %d %H:%M:%S %Y] "
        JkRequestLogFormat    "%w %V %T"
        JkShmFile logs/jk.shm
</IfModule>

JkWorkersFIle conf/workers.properties : 연동할 톰캣(worker) 지정
JkMountFile conf/url.properties : worker 지정할 url 패턴 지정

Apache와 Tomcat을 연동할 때 AJP Connector 포트를 사용한다. 디폴트는 8009이다.
Tomcat AJP Connector 포트 확인
1
vi /home/test/server/tomcat/conf/server.xml
cs
 
- workers.properties
1
vi /home/test/server/apache/conf/workers.properties
cs

1
2
3
4
worker.list=worker1
worker.worker1.type=ajp13
worker.worker1.host=192.168.0.6
worker.worker1.port=8009
cs


- url.properties 
1
vi /home/test/server/apache/conf/url.properties
cs

1
2
/*.do=worker1
/*.jsp=worker1
cs
 
- 톰캣 AJP 방화벽 포트 열기
여기서는 하나의 서버에서 진행하기 때문에 필요는 없지만 다른 서버에 설치할 경우 해당 포트를 열어줘야 한다.
1
2
sudo firewall-cmd --permanent --zone=public --add-port=8009/tcp
sudo firewall-cmd --reload
cs
 
- Apache web server 재시작 연동 확인
1
service httpd restart
cs
 
1
curl localhost
cs
<html><body><h1>It works!</h1></body></html>
 
1
curl localhost/index.jsp
cs
……
            <p class="copyright">Copyright &copy;1999-2018 Apache Software Foundation.  All Rights Reserved</p>
        </div>
    </body>
 
</html>


Comments