Centos 7 리눅스에 Apache Tomcat 8.5.79 설치하기
CentOS 7 리눅스 서버에서 Apache Tomcat 8.5.79 설치 방법에 대해 알아보고, 실습 내용을 통해 쉽게 Apache Tomcat WAS 서버를 설치하여 사용할 수 있습니다.
아파치 톰캣(Apache Tomcat)은 웹 서버와 연동하여 실행할 수 있는 자바 환경을 제공하여 자바 서버 페이지(JSP)와 자바 서블릿을 실행할 수 있는 환경을 제공하며, 설정 변경은 관리 툴을 이용하여 변경하거나 설정 파일을 직접 편집하여 설정할 수 있습니다. 톰캣은 동적 웹 페이지(Dynamic Web Page)를 위한 웹 컨테이너, 서블릿 컨테이너라고도 불리며, 웹 서버에서 처리해야 할 정적 콘텐츠를 제외한 DB 연동 및 동적 콘텐츠를 제공합니다. 웹 서버와 연동하지 않더라도 톰캣 5.5 버전부터 정적 콘텐츠 처리 기능을 포함하고 있기 때문에 아파치 톰캣만으로도 웹 서비스를 제공할 수 있습니다. 하지만, 톰캣만으로 웹 서비스 제공 시 정적 콘텐츠 및 동적 콘텐츠를 함께 처리해야 하므로 부하 분산을 위해 웹 서버(WEB)와 웹 애플리케이션 서버(WAS)로 역할을 분담하여 구성하는 게 효율적입니다.
환경 정보
- 운영 체제 : CentOS 7.9
- 실행 계정 : root
- SSH 접속 및 외부 인터넷이 가능한 네트워크 구성
OpenJDK 설치하기
Apache Tomcat 8.5.x 버전을 실행하려면 Java SE 7 이상이 필요하며, 이 문서에서는 JDK(Java Development Kit)를 오픈 소스인 OpenJDK 8 버전을 설치합니다.
OpenJDK 11 버전을 설치하려면 CentOS 7 리눅스에 YUM으로 Java OpenJDK 11 설치하기 글을 참조하여 설치하시면 됩니다.
설치할 수 있는 OpenJDK 버전 확인하기
YUM 리포지토리에서 설치할 수 있는 OpenJDK 버전 목록을 확인합니다.
yum list java*jdk-devel
[root@infracody.com ~]# yum list java*jdk-devel Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.navercorp.com * epel: ftp.riken.jp * extras: mirror.navercorp.com * updates: mirror.navercorp.com Available Packages java-1.6.0-openjdk-devel.x86_64 1:1.6.0.41-1.13.13.1.el7_3 base java-1.7.0-openjdk-devel.x86_64 1:1.7.0.261-2.6.22.2.el7_8 base java-1.8.0-openjdk-devel.i686 1:1.8.0.332.b09-1.el7_9 updates java-1.8.0-openjdk-devel.x86_64 1:1.8.0.332.b09-1.el7_9 updates java-11-openjdk-devel.i686 1:11.0.15.0.9-2.el7_9 updates java-11-openjdk-devel.x86_64 1:11.0.15.0.9-2.el7_9 updates java-latest-openjdk-devel.x86_64 1:18.0.1.0.10-2.rolling.el7 epel
OpenJDK 8 설치하기
설치할 수 있는 OpenJDK 목록 중 java-1.8.0-openjdk-devel.x86_64
패키지를 설치합니다.
yum install -y java-1.8.0-openjdk-devel.x86_64
[root@infracody.com ~]# yum install -y java-1.8.0-openjdk-devel.x86_64 Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.navercorp.com * epel: ftp.riken.jp * extras: mirror.navercorp.com * updates: mirror.navercorp.com Resolving Dependencies --> Running transaction check ---> Package java-1.8.0-openjdk-devel.x86_64 1:1.8.0.332.b09-1.el7_9 will be installed --> Processing Dependency: java-1.8.0-openjdk(x86-64) = 1:1.8.0.332.b09-1.el7_9 for package: 1:java-1.8.0-openjdk-devel-1.8.0.332.b09-1.el7_9.x86_64 --> Processing Dependency: libjvm.so()(64bit) for package: 1:java-1.8.0-openjdk-devel-1.8.0.332.b09-1.el7_9.x86_64 --> Processing Dependency: libjava.so()(64bit) for package: 1:java-1.8.0-openjdk-devel-1.8.0.332.b09-1.el7_9.x86_64 --> Running transaction check ---> Package java-1.8.0-openjdk.x86_64 1:1.8.0.332.b09-1.el7_9 will be installed --> Processing Dependency: libXcomposite(x86-64) for package: 1:java-1.8.0-openjdk-1.8.0.332.b09-1.el7_9.x86_64 --> Processing Dependency: gtk2(x86-64) for package: 1:java-1.8.0-openjdk-1.8.0.332.b09-1.el7_9.x86_64 ---> Package java-1.8.0-openjdk-headless.x86_64 1:1.8.0.332.b09-1.el7_9 will be installed --> Running transaction check ---> Package gtk2.x86_64 0:2.24.31-1.el7 will be installed --> Processing Dependency: pango >= 1.20.0-1 for package: gtk2-2.24.31-1.el7.x86_64 --> Processing Dependency: libtiff >= 3.6.1 for package: gtk2-2.24.31-1.el7.x86_64 --> Processing Dependency: libXrandr >= 1.2.99.4-2 for package: gtk2-2.24.31-1.el7.x86_64 --> Processing Dependency: atk >= 1.29.4-2 for package: gtk2-2.24.31-1.el7.x86_64 --> Processing Dependency: hicolor-icon-theme for package: gtk2-2.24.31-1.el7.x86_64 --> Processing Dependency: gtk-update-icon-cache for package: gtk2-2.24.31-1.el7.x86_64 --> Processing Dependency: libpangoft2-1.0.so.0()(64bit) for package: gtk2-2.24.31-1.el7.x86_64 --> Processing Dependency: libpangocairo-1.0.so.0()(64bit) for package: gtk2-2.24.31-1.el7.x86_64 --> Processing Dependency: libpango-1.0.so.0()(64bit) for package: gtk2-2.24.31-1.el7.x86_64 --> Processing Dependency: libgdk_pixbuf-2.0.so.0()(64bit) for package: gtk2-2.24.31-1.el7.x86_64 --> Processing Dependency: libcairo.so.2()(64bit) for package: gtk2-2.24.31-1.el7.x86_64 --> Processing Dependency: libatk-1.0.so.0()(64bit) for package: gtk2-2.24.31-1.el7.x86_64 --> Processing Dependency: libXrandr.so.2()(64bit) for package: gtk2-2.24.31-1.el7.x86_64 --> Processing Dependency: libXinerama.so.1()(64bit) for package: gtk2-2.24.31-1.el7.x86_64 --> Processing Dependency: libXfixes.so.3()(64bit) for package: gtk2-2.24.31-1.el7.x86_64 --> Processing Dependency: libXdamage.so.1()(64bit) for package: gtk2-2.24.31-1.el7.x86_64 --> Processing Dependency: libXcursor.so.1()(64bit) for package: gtk2-2.24.31-1.el7.x86_64 ---> Package libXcomposite.x86_64 0:0.4.4-4.1.el7 will be installed --> Running transaction check ---> Package atk.x86_64 0:2.28.1-2.el7 will be installed ---> Package cairo.x86_64 0:1.15.12-4.el7 will be installed --> Processing Dependency: libpixman-1.so.0()(64bit) for package: cairo-1.15.12-4.el7.x86_64 --> Processing Dependency: libGL.so.1()(64bit) for package: cairo-1.15.12-4.el7.x86_64 --> Processing Dependency: libEGL.so.1()(64bit) for package: cairo-1.15.12-4.el7.x86_64 ---> Package gdk-pixbuf2.x86_64 0:2.36.12-3.el7 will be installed --> Processing Dependency: libjasper.so.1()(64bit) for package: gdk-pixbuf2-2.36.12-3.el7.x86_64 ---> Package gtk-update-icon-cache.x86_64 0:3.22.30-8.el7_9 will be installed ---> Package hicolor-icon-theme.noarch 0:0.12-7.el7 will be installed ---> Package libXcursor.x86_64 0:1.1.15-1.el7 will be installed ---> Package libXdamage.x86_64 0:1.1.4-4.1.el7 will be installed ---> Package libXfixes.x86_64 0:5.0.3-1.el7 will be installed ---> Package libXinerama.x86_64 0:1.1.3-2.1.el7 will be installed ---> Package libXrandr.x86_64 0:1.5.1-2.el7 will be installed ---> Package libtiff.x86_64 0:4.0.3-35.el7 will be installed --> Processing Dependency: libjbig.so.2.0()(64bit) for package: libtiff-4.0.3-35.el7.x86_64 ---> Package pango.x86_64 0:1.42.4-4.el7_7 will be installed --> Processing Dependency: libthai(x86-64) >= 0.1.9 for package: pango-1.42.4-4.el7_7.x86_64 --> Processing Dependency: libXft(x86-64) >= 2.0.0 for package: pango-1.42.4-4.el7_7.x86_64 --> Processing Dependency: harfbuzz(x86-64) >= 1.4.2 for package: pango-1.42.4-4.el7_7.x86_64 --> Processing Dependency: fribidi(x86-64) >= 1.0 for package: pango-1.42.4-4.el7_7.x86_64 --> Processing Dependency: libthai.so.0(LIBTHAI_0.1)(64bit) for package: pango-1.42.4-4.el7_7.x86_64 --> Processing Dependency: libthai.so.0()(64bit) for package: pango-1.42.4-4.el7_7.x86_64 --> Processing Dependency: libharfbuzz.so.0()(64bit) for package: pango-1.42.4-4.el7_7.x86_64 --> Processing Dependency: libfribidi.so.0()(64bit) for package: pango-1.42.4-4.el7_7.x86_64 --> Processing Dependency: libXft.so.2()(64bit) for package: pango-1.42.4-4.el7_7.x86_64 --> Running transaction check ---> Package fribidi.x86_64 0:1.0.2-1.el7_7.1 will be installed ---> Package harfbuzz.x86_64 0:1.7.5-2.el7 will be installed --> Processing Dependency: libgraphite2.so.3()(64bit) for package: harfbuzz-1.7.5-2.el7.x86_64 ---> Package jasper-libs.x86_64 0:1.900.1-33.el7 will be installed ---> Package jbigkit-libs.x86_64 0:2.0-11.el7 will be installed ---> Package libXft.x86_64 0:2.3.2-2.el7 will be installed ---> Package libglvnd-egl.x86_64 1:1.0.1-0.8.git5baa1e5.el7 will be installed --> Processing Dependency: libglvnd(x86-64) = 1:1.0.1-0.8.git5baa1e5.el7 for package: 1:libglvnd-egl-1.0.1-0.8.git5baa1e5.el7.x86_64 --> Processing Dependency: mesa-libEGL(x86-64) >= 13.0.4-1 for package: 1:libglvnd-egl-1.0.1-0.8.git5baa1e5.el7.x86_64 --> Processing Dependency: libGLdispatch.so.0()(64bit) for package: 1:libglvnd-egl-1.0.1-0.8.git5baa1e5.el7.x86_64 ---> Package libglvnd-glx.x86_64 1:1.0.1-0.8.git5baa1e5.el7 will be installed --> Processing Dependency: mesa-libGL(x86-64) >= 13.0.4-1 for package: 1:libglvnd-glx-1.0.1-0.8.git5baa1e5.el7.x86_64 ---> Package libthai.x86_64 0:0.1.14-9.el7 will be installed ---> Package pixman.x86_64 0:0.34.0-1.el7 will be installed --> Running transaction check ---> Package graphite2.x86_64 0:1.3.10-1.el7_3 will be installed ---> Package libglvnd.x86_64 1:1.0.1-0.8.git5baa1e5.el7 will be installed ---> Package mesa-libEGL.x86_64 0:18.3.4-12.el7_9 will be installed --> Processing Dependency: mesa-libgbm = 18.3.4-12.el7_9 for package: mesa-libEGL-18.3.4-12.el7_9.x86_64 --> Processing Dependency: libxshmfence.so.1()(64bit) for package: mesa-libEGL-18.3.4-12.el7_9.x86_64 --> Processing Dependency: libwayland-server.so.0()(64bit) for package: mesa-libEGL-18.3.4-12.el7_9.x86_64 --> Processing Dependency: libwayland-client.so.0()(64bit) for package: mesa-libEGL-18.3.4-12.el7_9.x86_64 --> Processing Dependency: libglapi.so.0()(64bit) for package: mesa-libEGL-18.3.4-12.el7_9.x86_64 --> Processing Dependency: libgbm.so.1()(64bit) for package: mesa-libEGL-18.3.4-12.el7_9.x86_64 ---> Package mesa-libGL.x86_64 0:18.3.4-12.el7_9 will be installed --> Processing Dependency: libXxf86vm.so.1()(64bit) for package: mesa-libGL-18.3.4-12.el7_9.x86_64 --> Running transaction check ---> Package libXxf86vm.x86_64 0:1.1.4-1.el7 will be installed ---> Package libwayland-client.x86_64 0:1.15.0-1.el7 will be installed ---> Package libwayland-server.x86_64 0:1.15.0-1.el7 will be installed ---> Package libxshmfence.x86_64 0:1.2-1.el7 will be installed ---> Package mesa-libgbm.x86_64 0:18.3.4-12.el7_9 will be installed ---> Package mesa-libglapi.x86_64 0:18.3.4-12.el7_9 will be installed --> Finished Dependency Resolution Dependencies Resolved ===================================================================================================================================================================================================================================== Package Arch Version Repository Size ===================================================================================================================================================================================================================================== Installing: java-1.8.0-openjdk-devel x86_64 1:1.8.0.332.b09-1.el7_9 updates 9.8 M Installing for dependencies: atk x86_64 2.28.1-2.el7 base 263 k cairo x86_64 1.15.12-4.el7 base 741 k fribidi x86_64 1.0.2-1.el7_7.1 base 79 k gdk-pixbuf2 x86_64 2.36.12-3.el7 base 570 k graphite2 x86_64 1.3.10-1.el7_3 base 115 k gtk-update-icon-cache x86_64 3.22.30-8.el7_9 updates 27 k gtk2 x86_64 2.24.31-1.el7 base 3.4 M harfbuzz x86_64 1.7.5-2.el7 base 267 k hicolor-icon-theme noarch 0.12-7.el7 base 42 k jasper-libs x86_64 1.900.1-33.el7 base 150 k java-1.8.0-openjdk x86_64 1:1.8.0.332.b09-1.el7_9 updates 314 k java-1.8.0-openjdk-headless x86_64 1:1.8.0.332.b09-1.el7_9 updates 33 M jbigkit-libs x86_64 2.0-11.el7 base 46 k libXcomposite x86_64 0.4.4-4.1.el7 base 22 k libXcursor x86_64 1.1.15-1.el7 base 30 k libXdamage x86_64 1.1.4-4.1.el7 base 20 k libXfixes x86_64 5.0.3-1.el7 base 18 k libXft x86_64 2.3.2-2.el7 base 58 k libXinerama x86_64 1.1.3-2.1.el7 base 14 k libXrandr x86_64 1.5.1-2.el7 base 27 k libXxf86vm x86_64 1.1.4-1.el7 base 18 k libglvnd x86_64 1:1.0.1-0.8.git5baa1e5.el7 base 89 k libglvnd-egl x86_64 1:1.0.1-0.8.git5baa1e5.el7 base 44 k libglvnd-glx x86_64 1:1.0.1-0.8.git5baa1e5.el7 base 125 k libthai x86_64 0.1.14-9.el7 base 187 k libtiff x86_64 4.0.3-35.el7 base 172 k libwayland-client x86_64 1.15.0-1.el7 base 33 k libwayland-server x86_64 1.15.0-1.el7 base 39 k libxshmfence x86_64 1.2-1.el7 base 7.2 k mesa-libEGL x86_64 18.3.4-12.el7_9 updates 110 k mesa-libGL x86_64 18.3.4-12.el7_9 updates 166 k mesa-libgbm x86_64 18.3.4-12.el7_9 updates 39 k mesa-libglapi x86_64 18.3.4-12.el7_9 updates 46 k pango x86_64 1.42.4-4.el7_7 base 280 k pixman x86_64 0.34.0-1.el7 base 248 k Transaction Summary ===================================================================================================================================================================================================================================== Install 1 Package (+35 Dependent packages) Total download size: 51 M Installed size: 177 M Downloading packages: (1/36): atk-2.28.1-2.el7.x86_64.rpm | 263 kB 00:00:00 (2/36): fribidi-1.0.2-1.el7_7.1.x86_64.rpm | 79 kB 00:00:00 (3/36): cairo-1.15.12-4.el7.x86_64.rpm | 741 kB 00:00:00 (4/36): graphite2-1.3.10-1.el7_3.x86_64.rpm | 115 kB 00:00:00 (5/36): gdk-pixbuf2-2.36.12-3.el7.x86_64.rpm | 570 kB 00:00:00 (6/36): harfbuzz-1.7.5-2.el7.x86_64.rpm | 267 kB 00:00:00 (7/36): hicolor-icon-theme-0.12-7.el7.noarch.rpm | 42 kB 00:00:00 (8/36): jasper-libs-1.900.1-33.el7.x86_64.rpm | 150 kB 00:00:00 (9/36): gtk-update-icon-cache-3.22.30-8.el7_9.x86_64.rpm | 27 kB 00:00:00 (10/36): gtk2-2.24.31-1.el7.x86_64.rpm | 3.4 MB 00:00:00 (11/36): java-1.8.0-openjdk-1.8.0.332.b09-1.el7_9.x86_64.rpm | 314 kB 00:00:00 (12/36): libXcomposite-0.4.4-4.1.el7.x86_64.rpm | 22 kB 00:00:00 (13/36): jbigkit-libs-2.0-11.el7.x86_64.rpm | 46 kB 00:00:00 (14/36): java-1.8.0-openjdk-devel-1.8.0.332.b09-1.el7_9.x86_64.rpm | 9.8 MB 00:00:00 (15/36): libXdamage-1.1.4-4.1.el7.x86_64.rpm | 20 kB 00:00:00 (16/36): libXfixes-5.0.3-1.el7.x86_64.rpm | 18 kB 00:00:00 (17/36): libXcursor-1.1.15-1.el7.x86_64.rpm | 30 kB 00:00:00 (18/36): libXinerama-1.1.3-2.1.el7.x86_64.rpm | 14 kB 00:00:00 (19/36): libXft-2.3.2-2.el7.x86_64.rpm | 58 kB 00:00:00 (20/36): libXxf86vm-1.1.4-1.el7.x86_64.rpm | 18 kB 00:00:00 (21/36): libXrandr-1.5.1-2.el7.x86_64.rpm | 27 kB 00:00:00 (22/36): libglvnd-1.0.1-0.8.git5baa1e5.el7.x86_64.rpm | 89 kB 00:00:00 (23/36): libglvnd-egl-1.0.1-0.8.git5baa1e5.el7.x86_64.rpm | 44 kB 00:00:00 (24/36): java-1.8.0-openjdk-headless-1.8.0.332.b09-1.el7_9.x86_64.rpm | 33 MB 00:00:01 (25/36): libglvnd-glx-1.0.1-0.8.git5baa1e5.el7.x86_64.rpm | 125 kB 00:00:00 (26/36): libtiff-4.0.3-35.el7.x86_64.rpm | 172 kB 00:00:00 (27/36): libthai-0.1.14-9.el7.x86_64.rpm | 187 kB 00:00:00 (28/36): libwayland-client-1.15.0-1.el7.x86_64.rpm | 33 kB 00:00:00 (29/36): libwayland-server-1.15.0-1.el7.x86_64.rpm | 39 kB 00:00:00 (30/36): mesa-libEGL-18.3.4-12.el7_9.x86_64.rpm | 110 kB 00:00:00 (31/36): libxshmfence-1.2-1.el7.x86_64.rpm | 7.2 kB 00:00:00 (32/36): mesa-libgbm-18.3.4-12.el7_9.x86_64.rpm | 39 kB 00:00:00 (33/36): mesa-libglapi-18.3.4-12.el7_9.x86_64.rpm | 46 kB 00:00:00 (34/36): mesa-libGL-18.3.4-12.el7_9.x86_64.rpm | 166 kB 00:00:00 (35/36): pango-1.42.4-4.el7_7.x86_64.rpm | 280 kB 00:00:00 (36/36): pixman-0.34.0-1.el7.x86_64.rpm | 248 kB 00:00:00 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 16 MB/s | 51 MB 00:00:03 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : libXfixes-5.0.3-1.el7.x86_64 1/36 Installing : mesa-libglapi-18.3.4-12.el7_9.x86_64 2/36 Installing : libXdamage-1.1.4-4.1.el7.x86_64 3/36 Installing : libxshmfence-1.2-1.el7.x86_64 4/36 Installing : 1:libglvnd-1.0.1-0.8.git5baa1e5.el7.x86_64 5/36 Installing : libXcomposite-0.4.4-4.1.el7.x86_64 6/36 Installing : 1:java-1.8.0-openjdk-headless-1.8.0.332.b09-1.el7_9.x86_64 7/36 Installing : libwayland-server-1.15.0-1.el7.x86_64 8/36 Installing : mesa-libgbm-18.3.4-12.el7_9.x86_64 9/36 Installing : libXcursor-1.1.15-1.el7.x86_64 10/36 Installing : atk-2.28.1-2.el7.x86_64 11/36 Installing : graphite2-1.3.10-1.el7_3.x86_64 12/36 Installing : harfbuzz-1.7.5-2.el7.x86_64 13/36 Installing : jasper-libs-1.900.1-33.el7.x86_64 14/36 Installing : jbigkit-libs-2.0-11.el7.x86_64 15/36 Installing : libtiff-4.0.3-35.el7.x86_64 16/36 Installing : gdk-pixbuf2-2.36.12-3.el7.x86_64 17/36 Installing : gtk-update-icon-cache-3.22.30-8.el7_9.x86_64 18/36 Installing : pixman-0.34.0-1.el7.x86_64 19/36 Installing : libXrandr-1.5.1-2.el7.x86_64 20/36 Installing : libXft-2.3.2-2.el7.x86_64 21/36 Installing : libthai-0.1.14-9.el7.x86_64 22/36 Installing : fribidi-1.0.2-1.el7_7.1.x86_64 23/36 Installing : hicolor-icon-theme-0.12-7.el7.noarch 24/36 Installing : libXxf86vm-1.1.4-1.el7.x86_64 25/36 Installing : mesa-libGL-18.3.4-12.el7_9.x86_64 26/36 Installing : 1:libglvnd-glx-1.0.1-0.8.git5baa1e5.el7.x86_64 27/36 Installing : libXinerama-1.1.3-2.1.el7.x86_64 28/36 Installing : libwayland-client-1.15.0-1.el7.x86_64 29/36 Installing : 1:libglvnd-egl-1.0.1-0.8.git5baa1e5.el7.x86_64 30/36 Installing : mesa-libEGL-18.3.4-12.el7_9.x86_64 31/36 Installing : cairo-1.15.12-4.el7.x86_64 32/36 Installing : pango-1.42.4-4.el7_7.x86_64 33/36 Installing : gtk2-2.24.31-1.el7.x86_64 34/36 Installing : 1:java-1.8.0-openjdk-1.8.0.332.b09-1.el7_9.x86_64 35/36 Installing : 1:java-1.8.0-openjdk-devel-1.8.0.332.b09-1.el7_9.x86_64 36/36 Verifying : libwayland-client-1.15.0-1.el7.x86_64 1/36 Verifying : gdk-pixbuf2-2.36.12-3.el7.x86_64 2/36 Verifying : libXinerama-1.1.3-2.1.el7.x86_64 3/36 Verifying : 1:libglvnd-glx-1.0.1-0.8.git5baa1e5.el7.x86_64 4/36 Verifying : libXxf86vm-1.1.4-1.el7.x86_64 5/36 Verifying : 1:java-1.8.0-openjdk-1.8.0.332.b09-1.el7_9.x86_64 6/36 Verifying : libwayland-server-1.15.0-1.el7.x86_64 7/36 Verifying : libXcursor-1.1.15-1.el7.x86_64 8/36 Verifying : 1:java-1.8.0-openjdk-headless-1.8.0.332.b09-1.el7_9.x86_64 9/36 Verifying : gtk2-2.24.31-1.el7.x86_64 10/36 Verifying : hicolor-icon-theme-0.12-7.el7.noarch 11/36 Verifying : libXcomposite-0.4.4-4.1.el7.x86_64 12/36 Verifying : mesa-libglapi-18.3.4-12.el7_9.x86_64 13/36 Verifying : libtiff-4.0.3-35.el7.x86_64 14/36 Verifying : pango-1.42.4-4.el7_7.x86_64 15/36 Verifying : fribidi-1.0.2-1.el7_7.1.x86_64 16/36 Verifying : libthai-0.1.14-9.el7.x86_64 17/36 Verifying : 1:libglvnd-1.0.1-0.8.git5baa1e5.el7.x86_64 18/36 Verifying : libXft-2.3.2-2.el7.x86_64 19/36 Verifying : mesa-libGL-18.3.4-12.el7_9.x86_64 20/36 Verifying : 1:java-1.8.0-openjdk-devel-1.8.0.332.b09-1.el7_9.x86_64 21/36 Verifying : harfbuzz-1.7.5-2.el7.x86_64 22/36 Verifying : libXrandr-1.5.1-2.el7.x86_64 23/36 Verifying : pixman-0.34.0-1.el7.x86_64 24/36 Verifying : jbigkit-libs-2.0-11.el7.x86_64 25/36 Verifying : cairo-1.15.12-4.el7.x86_64 26/36 Verifying : mesa-libgbm-18.3.4-12.el7_9.x86_64 27/36 Verifying : libxshmfence-1.2-1.el7.x86_64 28/36 Verifying : 1:libglvnd-egl-1.0.1-0.8.git5baa1e5.el7.x86_64 29/36 Verifying : gtk-update-icon-cache-3.22.30-8.el7_9.x86_64 30/36 Verifying : jasper-libs-1.900.1-33.el7.x86_64 31/36 Verifying : graphite2-1.3.10-1.el7_3.x86_64 32/36 Verifying : libXdamage-1.1.4-4.1.el7.x86_64 33/36 Verifying : libXfixes-5.0.3-1.el7.x86_64 34/36 Verifying : atk-2.28.1-2.el7.x86_64 35/36 Verifying : mesa-libEGL-18.3.4-12.el7_9.x86_64 36/36 Installed: java-1.8.0-openjdk-devel.x86_64 1:1.8.0.332.b09-1.el7_9 Dependency Installed: atk.x86_64 0:2.28.1-2.el7 cairo.x86_64 0:1.15.12-4.el7 fribidi.x86_64 0:1.0.2-1.el7_7.1 gdk-pixbuf2.x86_64 0:2.36.12-3.el7 graphite2.x86_64 0:1.3.10-1.el7_3 gtk-update-icon-cache.x86_64 0:3.22.30-8.el7_9 gtk2.x86_64 0:2.24.31-1.el7 harfbuzz.x86_64 0:1.7.5-2.el7 hicolor-icon-theme.noarch 0:0.12-7.el7 jasper-libs.x86_64 0:1.900.1-33.el7 java-1.8.0-openjdk.x86_64 1:1.8.0.332.b09-1.el7_9 java-1.8.0-openjdk-headless.x86_64 1:1.8.0.332.b09-1.el7_9 jbigkit-libs.x86_64 0:2.0-11.el7 libXcomposite.x86_64 0:0.4.4-4.1.el7 libXcursor.x86_64 0:1.1.15-1.el7 libXdamage.x86_64 0:1.1.4-4.1.el7 libXfixes.x86_64 0:5.0.3-1.el7 libXft.x86_64 0:2.3.2-2.el7 libXinerama.x86_64 0:1.1.3-2.1.el7 libXrandr.x86_64 0:1.5.1-2.el7 libXxf86vm.x86_64 0:1.1.4-1.el7 libglvnd.x86_64 1:1.0.1-0.8.git5baa1e5.el7 libglvnd-egl.x86_64 1:1.0.1-0.8.git5baa1e5.el7 libglvnd-glx.x86_64 1:1.0.1-0.8.git5baa1e5.el7 libthai.x86_64 0:0.1.14-9.el7 libtiff.x86_64 0:4.0.3-35.el7 libwayland-client.x86_64 0:1.15.0-1.el7 libwayland-server.x86_64 0:1.15.0-1.el7 libxshmfence.x86_64 0:1.2-1.el7 mesa-libEGL.x86_64 0:18.3.4-12.el7_9 mesa-libGL.x86_64 0:18.3.4-12.el7_9 mesa-libgbm.x86_64 0:18.3.4-12.el7_9 mesa-libglapi.x86_64 0:18.3.4-12.el7_9 pango.x86_64 0:1.42.4-4.el7_7 pixman.x86_64 0:0.34.0-1.el7 Complete!
OpenJDK 설치 확인하기
OpenJDK 8이 정상적으로 설치되었는지 자바 버전 확인 명령으로 확인합니다.
java -version
[root@infracody.com ~]# java -version openjdk version "1.8.0_332" OpenJDK Runtime Environment (build 1.8.0_332-b09) OpenJDK 64-Bit Server VM (build 25.332-b09, mixed mode)
Apache Tomcat 서비스 사용자 추가하기
톰캣 서비스를 root 계정으로 실행하면 보안상 취약하므로, 서비스 계정으로 사용할 tomcat 계정을 생성합니다.
톰캣이 설치 될 /usr/local/tomcat
디렉토리를 홈 디렉토리로 설정하고 -M
옵션으로 디렉토리 생성은 하지 않습니다. -s /sbin/nologin
옵션으로 ssh shell 로그인을 차단합니다.
useradd -d /usr/local/tomcat -M -s /sbin/nologin tomcat
Apache Tomcat 다운로드
wget 명령을 사용하여 톰캣 압축 파일을 다운 받습니다. wget 패키지가 설치되어 있지 않으면 yum install -y wget
명령을 실행하여 wget 설치 후 진행합니다.
톰캣을 /usr/local/
경로에 설치하기 위해 wget -P
옵션을 사용해서 저장 경로를 지정합니다.
wget https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.79/bin/apache-tomcat-8.5.79.zip -P /usr/local/
[root@infracody.com ~]# wget https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.79/bin/apache-tomcat-8.5.79.zip -P /usr/local/ --2022-05-30 09:24:10-- https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.79/bin/apache-tomcat-8.5.79.zip Resolving dlcdn.apache.org (dlcdn.apache.org)... 151.101.2.132, 2a04:4e42::644 Connecting to dlcdn.apache.org (dlcdn.apache.org)|151.101.2.132|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 11106031 (11M) [application/zip] Saving to: ‘/usr/local/apache-tomcat-8.5.79.zip’ apache-tomcat-8.5.79.zip 100%[==================================================================================================================================>] 10.59M --.-KB/s in 0.1s 2022-05-30 09:24:10 (104 MB/s) - ‘/usr/local/apache-tomcat-8.5.79.zip’ saved [11106031/11106031]
Apache Tomcat 압축 해제 및 심볼릭 링크 만들기
톰캣을 저장한 /usr/local/
디렉토리로 이동 후 unzip으로 압축 파일을 해제합니다. unzip 패키지 미설치 시 yum install -y unzip
명령을 실행하여 설치하시면 됩니다.
cd /usr/local/
unzip apache-tomcat-8.5.79.zip
apache-tomcat-8.5.79 디렉토리가 만들어졌는지 확인합니다.
ll -d apache-tomcat-8.5.79
[root@infracody.com ~]# ll -d apache-tomcat-8.5.79 drwxr-xr-x 9 root root 4.0K May 30 09:37 apache-tomcat-8.5.79/
톰캣 디렉토리의 버전 정보를 제외하고 간략하게 tomcat으로 사용하기 위해 /usr/local/tomcat
심볼릭 링크를 생성합니다.
ln -s apache-tomcat-8.5.79 tomcat
tomcat 심볼릭 링크가 생성되었는지 확인합니다. 심볼릭 링크를 통해 /usr/local/apache-tomcat-8.5.79
원본 디렉토리를 /usr/local/tomcat
에서 동일하게 사용할 수 있습니다.
ll -d tomcat
[root@infracody.com ~]# ll -d tomcat lrwxrwxrwx 1 root root 20 May 30 10:45 tomcat -> apache-tomcat-8.5.79/
Apache Tomcat 디렉토리와 실행 파일 권한 설정하기
tomcat 계정으로 서비스를 실행하기 위해 톰캣 패키지 디렉토리 권한을 변경합니다.
chown -R tomcat:tomcat /usr/local/apache-tomcat-8.5.79
톰캣의 bin 디렉토리 내 스크립트 파일에 실행 권한을 추가합니다.
chmod +x /usr/local/apache-tomcat-8.5.79/bin/*.sh
systemd에 tomcat 서비스 등록하기
다음 명령을 실행하여 /etc/systemd/system/tomcat.service
파일을 생성합니다.
cat <<EOF > /etc/systemd/system/tomcat.service
[Unit]
Description=Apache Tomcat Service
After=syslog.target network.target
[Service]
Type=forking
Environment="JAVA_HOME=/usr/local/java"
Environment="CATALINA_HOME=/usr/local/tomcat"
Environment="CATALINA_BASE=/usr/local/tomcat"
Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC"
Environment="JAVA_OPTS=-Djava.security.egd=file:///dev/urandom"
ExecStart=/usr/local/tomcat/bin/startup.sh
ExecStop=/usr/local/tomcat/bin/shutdown.sh
User=tomcat
Group=tomcat
[Install]
WantedBy=multi-user.target
EOF
systemd에 tomcat 서비스를 활성화하여 서버 시작 시 자동으로 tomcat 서비스를 시작하게 합니다.
systemctl enable tomcat
[root@infracody.com ~]# systemctl enable tomcat Created symlink /etc/systemd/system/multi-user.target.wants/tomcat.service → /etc/systemd/system/tomcat.service.
Apache Tomcat 서비스 시작하기
톰캣 서비스를 실행하고, 서비스 상태를 확인합니다.
systemctl start tomcat
systemctl status tomcat
[root@infracody.com ~]# systemctl status tomcat ● tomcat.service - Apache Tomcat Service Loaded: loaded (/etc/systemd/system/tomcat.service; enabled; vendor preset: disabled) Active: inactive (dead) since Tue 2022-05-31 00:03:03 KST; 2s ago Process: 3054 ExecStop=/usr/local/tomcat/bin/shutdown.sh (code=exited, status=0/SUCCESS) Process: 3046 ExecStart=/usr/local/tomcat/bin/startup.sh (code=exited, status=0/SUCCESS) May 31 00:03:03 infracody.com systemd[1]: Starting Apache Tomcat Service... May 31 00:03:03 infracody.com systemd[1]: tomcat.service: Succeeded. May 31 00:03:03 infracody.com systemd[1]: Started Apache Tomcat Service.
마무리
CentOS 7 리눅스에 Apache Tomcat 8.5.79 패키지를 설치하는 방법에 대해 알아보았습니다. 톰캣 패키지를 다운로드하고 tomcat 계정을 추가하여 서비스를 등록하고 사용하는 과정을 통해 쉽게 톰캣을 설치하고 사용할 수 있습니다.
- 블로그 : www.infracody.com
이 글이 유익했나요? 댓글로 소중한 의견을 남겨주시거나 커피 한 잔의 선물은 큰 힘이 됩니다.