DBDBDEEP

apache tomcat연동 방법에 대해 무던히 많이 찾았는데 잘 안되는 경우가 많다.

각 버전마다 라이브러리가 다르거나 linux 보안설정등 간단하지만 하나라도 맞지 않으면 오류가 나는 부분이 있는데

오류메시지에서 힌트를 얻기가 쉽지 않을 때가 많다.

최대한 간단하면서 붙여넣기만 하면 되도록 구성하였으나 만약 안된다면

각 s/w버전이 미묘하게(?) 다르거나 환경에 다소 차이가 있다는 것을 감안한다.

#CentOS 설정 추가

CentOS는 난해한(?)보안규칙으로 서비스 구성시에 에러가 자주발생한다.
권고되진 않는다곤 하지만 관련 selinux설정을 먼저 꺼준다.

#Selinix 끄기

vi /etc/sysconfig/selinux

SELINUX=enforcing SELINUX=disabled로 변경

재부팅

 

 

#centos8 버전으로 검색하면 Apache Tomcat 연동에 여러 문서가 있지만
http://progtrend.blogspot.com/2018/06/aws-apacheweb-server-tomcat.html
위 주소에 대한 설명이 가장 직관적이었다. AWS linux설정이었지만 centOS계열과 큰 차이가 없었음을 참고하자.

 

#web서버 사전 서비스 및 라이브러리 설치

yum install httpd

 

Failed to download metadata for repo 'AppStream'

혹 위에러가 난다면 인터넷연결이 안되는 부분이니 설정을 확인한다.

 

yum install gcc

yum install httpd-devel

// Apache 재시작에 문제가 없는지 확인한다.

$ sudo service httpd restart
systemctl enable httpd #시스템 재부팅시 apache서비스 자동시작

 

#tomcat에 연결을 도와주는 connerctor 설치

http://tomcat.apache.org/download-connectors.cgi

 

JK 1.2.48 Source Release tar.gz 를 활용해야한다.

위 파일을 압축을 풀고 아래 경로로 이동

/work/tomcat-connectors-1.2.48-src/native

 


[root@192 native]# ./configure --with-apxs=/usr/bin/apxs

checking build system type... x86_64-pc-linux-gnu

checking host system type... x86_64-pc-linux-gnu

checking target system type... x86_64-pc-linux-gnu

checking for a BSD-compatible install... /usr/bin/install -c

checking whether build environment is sane... yes

checking for a thread-safe mkdir -p... /usr/bin/mkdir -p

checking for gawk... gawk

checking whether make sets $(MAKE)... no

checking whether make supports nested variables... no

checking for test... /usr/bin/test

checking for grep... /usr/bin/grep

checking for echo... /usr/bin/echo

checking for sed... /usr/bin/sed

checking for cp... /usr/bin/cp

checking for mkdir... /usr/bin/mkdir

need to check for Perl first, apxs depends on it...

checking for perl... /usr/bin/perl

APRINCLUDEDIR is  -I/usr/include/apr-1 -I/usr/include/apr-1

building connector for "apache-2.0"

checking for gcc... gcc

checking whether the C compiler works... yes

checking for C compiler default output file name... a.out

checking for suffix of executables...

checking whether we are cross compiling... no

checking for suffix of object files... o

checking whether we are using the GNU C compiler... yes

checking whether gcc accepts -g... yes

checking for gcc option to accept ISO C89... none needed

checking whether gcc understands -c and -o together... yes

checking for style of include used by make... none

checking dependency style of gcc... none

checking for a sed that does not truncate output... (cached) /usr/bin/sed

checking for grep that handles long lines and -e... (cached) /usr/bin/grep

checking for egrep... /usr/bin/grep -E

checking for fgrep... /usr/bin/grep -F

checking how to print strings... printf

checking for ld used by gcc... /usr/bin/ld

checking if the linker (/usr/bin/ld) is GNU ld... yes

checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B

checking the name lister (/usr/bin/nm -B) interface... BSD nm

checking whether ln -s works... yes

checking the maximum length of command line arguments... 1572864

checking how to convert x86_64-pc-linux-gnu file names to x86_64-pc-linux-gnu format... func_convert_file_noop

checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop

checking for /usr/bin/ld option to reload object files... -r

checking for objdump... objdump

checking how to recognize dependent libraries... pass_all

checking for dlltool... no

checking how to associate runtime and link libraries... printf %s\n

checking for ar... ar

checking for archiver @FILE support... @

checking for strip... strip

checking for ranlib... ranlib

checking command to parse /usr/bin/nm -B output from gcc object... ok

checking for sysroot... no

checking for a working dd... /usr/bin/dd

checking how to truncate binary pipes... /usr/bin/dd bs=4096 count=1

checking for mt... no

checking if : is a manifest tool... no

checking how to run the C preprocessor... gcc -E

checking for ANSI C header files... yes

checking for sys/types.h... yes

checking for sys/stat.h... yes

checking for stdlib.h... yes

checking for string.h... yes

checking for memory.h... yes

checking for strings.h... yes

checking for inttypes.h... yes

checking for stdint.h... yes

checking for unistd.h... yes

checking for dlfcn.h... yes

checking for objdir... .libs

checking if gcc supports -fno-rtti -fno-exceptions... no

checking for gcc option to produce PIC... -fPIC -DPIC

checking if gcc PIC flag -fPIC -DPIC works... yes

checking if gcc static flag -static works... no

checking if gcc supports -c -o file.o... yes

checking if gcc supports -c -o file.o... (cached) yes

checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes

checking whether -lc should be explicitly linked in... no

checking dynamic linker characteristics... GNU/Linux ld.so

checking how to hardcode library paths into programs... immediate

checking for shl_load... no

checking for shl_load in -ldld... no

checking for dlopen... no

checking for dlopen in -ldl... yes

checking whether a program can dlopen itself... yes

checking whether a statically linked program can dlopen itself... yes

checking whether stripping libraries is possible... yes

checking if libtool supports shared libraries... yes

checking whether to build shared libraries... yes

checking whether to build static libraries... yes

LIBTOOL="/usr/lib64/apr-1/build/libtool --silent"

checking size of char... 1

checking size of int... 4

checking size of long... 8

checking size of short... 2

checking size of long double... 16

checking size of long long... 8

checking size of longlong... 0

checking size of pid_t... 4

checking size of pthread_t... 8

checking for snprintf... yes

checking for vsnprintf... yes

checking for flock... yes

checking for setsockopt in -lsocket... no

checking sys/filio.h usability... no

checking sys/filio.h presence... no

checking for sys/filio.h... no

checking whether to use SO_RCVTIMEO with setsockopt()... yes

checking whether to use SO_SNDTIMEO with setsockopt()... yes

checking whether to use SOCK_CLOEXEC with socket()... yes

checking poll.h usability... yes

checking poll.h presence... yes

checking for poll.h... yes

checking for poll... yes

checking netinet/in.h usability... yes

checking netinet/in.h presence... yes

checking for netinet/in.h... yes

checking netdb.h usability... yes

checking netdb.h presence... yes

checking for netdb.h... yes

checking for IPv6 with socket()... yes

checking for struct sockaddr_storage... yes

checking for getaddrinfo... yes

checking for gethostbyname_r... yes

checking whether the compiler provides atomic builtins... yes

checking for target platform... unix

no apache given

no netscape given

checking that generated files are newer than configure... done

configure: creating ./config.status

config.status: creating Makefile

config.status: creating apache-2.0/Makefile

config.status: creating apache-2.0/Makefile.apxs

config.status: creating common/Makefile

config.status: creating common/list.mk

config.status: creating common/jk_types.h

config.status: creating common/config.h

config.status: executing depfiles commands

config.status: executing libtool commands

 


yum install make  #이미 make가 있다면 skip 한다.

make  #gcc: error: /usr/lib/rpm/redhat/redhat-hardened-cc1: 그런 파일이나 디렉터리가 없다는 에러 발생시  yum install redhat-rpm-config 수행후 다시 make

(libtool: warning: remember to run 'libtool --finish /usr/lib64/httpd/modules' 메시지는 나왔으나 skip)

make install

chmod 755 /usr/lib64/httpd/modules/mod_jk.so

 

 

 

#was서버 tomcat 설치

Tomcat yum install로 할 수도 있으나 직접 다운로드 받고 복수의 tomcat을 설정하는 경우도 있으므로

직관적으로 편한 공식 홈페이지에서 다운받고 설치하는 방법으로 진행하겠다.

tar -zxvf apache-tomcat-8.5.56.tar.gz

 

tomcat 설치경로/server.xml 에서

<Connector port="8009" protocol="AJP/1.3" redirectport="8443">  #주석이 <!-- --> 되어있으면 제거해준다.

 

/etc/httpd/conf.modules.d 경로에서 mod_jk.conf 파일 생성 후 아래 내용으로 저장

# Load mod_jk module

LoadModule jk_module modules/mod_jk.so

 

# Where to find workers.properties

JkWorkersFile conf/workers.properties

 

# Where to put jk shared memory file

JkShmFile run/mod_jk.shm

 

# Where to put jk logs

JkLogFile logs/mod_jk.log

 

# Set the jk log level [debug/error/info]

JkLogLevel info

 

# Send all requests to worker named ajp13

JkMount /* ajp13worker

 

/etc/httpd/conf 경로의 workers.properties 파일 생성

worker.list=ajp13worker

worker.ajp13worker.type=ajp13

#worker.ajp13worker.host=localhost

worker.ajp13worker.host=192.168.88.139      #was서버주소 입력

worker.ajp13worker.port=8009

worker.ajp13worker.connection_pool_timeout=600

worker.ajp13worker.socket_keepalive=1

 

아파치 서비스 재시작후 정상동작 확인

service httpd restart

localhostip모두 접속하여 테스트해본다.
톰캣서비스의 고양이 얼굴이 보인다면 정상

 

이 글을 공유합시다

facebook twitter googleplus kakaoTalk kakaostory naver band