Docker 톰캣 WAS 설치
보통 WEB, WAS, DB는 각각의 서버들을 세팅하여 사용하지만
VMware 리눅스 가상머신에 도커로 컨테이너를 생성하여 사용해본다.
정석은 APM(Apache, PHP, MySQL -> MariaDB) 삼신기를 설치하는 것이지만
한국에는 PHP보다는 jsp가 잘 먹힌다고 해서 톰캣으로 jps환경을 세팅한다.
사실 허접한 개인 홈페이지라 아파치 웹서버 대신 톰캣 WAS를 WEB서버로 같이 사용해도 되지만
부하 방지를 위해 실무에서 아래처럼 많이들 구성한다고 하길래 따라 해 본다.
클라이언트에서 아파치 웹서버로(80번 포트) 서비스 요청을 하면
정적 페이지(HTML)는 아파치가 처리하고
동적 페이지(JSP)는 아파치가 톰캣에 처리하라고 전달해준다.
아파치 웹서버 설치는 지난 포스팅 참조.
https://sansan2.tistory.com/10
Ubuntu(우분투) 리눅스 Docker에 아파치(httpd) 웹서버 설치
그냥 우분투 리눅스에 아파치를 설치해서 사용 가능 하지만 도커가 대세라고하니 도커로 설치해본다. 설치할 웹서버는 아파치. 이유는 아래 참조. 1. Docker 웹서버 컨테이너 설치 방법 우선 아파
sansan2.tistory.com
도커 톰캣 설치
docker search tomcat
오피셜 버전으로 받는다
docker pull tomcat
다운로드가 완료되면
docker images 명령어로 이미지를 확인 후
docker run -d --nmae tomcat -p 8080:80 --hostnmae tomcat tomcat
컨테이너 생성
docker exec -it tomcat bash로 톰캣 컨테이너 접속
root@tomcat:/usr/local/tomcat# ls -l
total 164
-rw-r--r-- 1 root root 19010 Jun 2 16:53 BUILDING.txt
-rw-r--r-- 1 root root 6210 Jun 2 16:53 CONTRIBUTING.md
-rw-r--r-- 1 root root 60269 Jun 2 16:53 LICENSE
-rw-r--r-- 1 root root 2333 Jun 2 16:53 NOTICE
-rw-r--r-- 1 root root 3398 Jun 2 16:53 README.md
-rw-r--r-- 1 root root 6908 Jun 2 16:53 RELEASE-NOTES
-rw-r--r-- 1 root root 16515 Jun 2 16:53 RUNNING.txt
drwxr-xr-x 2 root root 4096 Jun 13 20:15 bin
drwxr-xr-x 1 root root 4096 Jun 20 04:18 conf
drwxr-xr-x 2 root root 4096 Jun 13 20:14 lib
drwxrwxrwx 1 root root 4096 Jun 20 03:50 logs
drwxr-xr-x 2 root root 4096 Jun 13 20:15 native-jni-lib
drwxrwxrwx 2 root root 4096 Jun 13 20:14 temp
drwxr-xr-x 8 root root 4096 Jun 19 17:12 webapps
drwxr-xr-x 3 root root 4096 Jun 19 17:01 webapps2
drwxrwxrwx 1 root root 4096 Jun 19 17:01 work
root@tomcat:/usr/local/tomcat# cd webapps
mkdir ROOT
cd ROOT
webapps에 ROOT 디렉터리가 없어서 생성
apt update
apt install vim
vim text.html
간단하게 정적 홈페이지를 만들기 위해 vim 설치
<!DOCTYPE html>
<html>
<head>
<title>잡동산산이</title>
</head>
<body>
<h5>잡동산산이의 웹 페이지 입니다</h5>
<hr>
<a href='https://sansan2.tistory.com/'>잡동산산이블로그<br></a>
<a href='https://www.google.com/'>구글<br></a>
<a href='https://www.naver.com/'>네이버<br></a>
</body>
</html>
HTML 대충 작성
vim /usr/local/tomcat/conf/web.xml
시작페이지 설정을 위해 web.xml 수정
<welcome-file-list>
<welcome-file>test.html</welcome-file>
</welcome-file-list>
맨 아랫줄 톰캣 호랑이를 불러오는 녀석들을 다 제거하고
방금 전 만들었던 test.html 파일을 위에처럼 넣고 저장
톰캣을 웹서버 겸용으로 테스트
끗