본문 바로가기
OS & Server/Linux

[Centos7] Apache Tomcat10 설치

by 주리니e 2022. 7. 15.
728x90

[Centos7] Apache Tomcat10 설치

 

 

Apache Tomcat 구동 시 JAVA 설치가 미리 되어있어야 한다.
2022.07.14 - [OS/Linux] - [Centos7] Open JDK11 (JAVA Development Kit) 설치

 

[Centos7] Open JDK11 (JAVA Development Kit) 설치

[Centos7] Open JDK11 (JAVA Development Kit)  설치 JAVA 설치 여부 확인 $ java -version -bash: java: command not found $ which java /usr/bin/which: no java in (/usr/local/bin:/usr/bin:/usr/loc..

jiurinie.tistory.com

 

https://tomcat.apache.org/

 

Apache Tomcat® - Welcome!

The Apache Tomcat® software is an open source implementation of the Jakarta Servlet, Jakarta Server Pages, Jakarta Expression Language, Jakarta WebSocket, Jakarta Annotations and Jakarta Authentication specifications. These specifications are part of the

tomcat.apache.org

 

 

위 Apache Tomcat 사이트에 접속하여 Tomcat10 - Core - tar.gz - 링크 주소 복사를 한다.

 

# 디렉토리 이동
$ cd /usr/share

# wget을 이용해 Apache Tomcat 다운로드
$ wget https://dlcdn.apache.org/tomcat/tomcat-10/v10.0.22/bin/apache-tomcat-10.0.22.tar.gz
--2022-07-15 13:44:45--  https://dlcdn.apache.org/tomcat/tomcat-10/v10.0.22/bin/apache-tomcat-10.0.22.tar.gz
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.
ERROR: cannot verify dlcdn.apache.org's certificate, issued by ‘/C=US/O=Let's Encrypt/CN=R3’:
  Issued certificate has expired.
  
$ wget https://dlcdn.apache.org/tomcat/tomcat-10/v10.0.22/bin/apache-tomcat-10.0.22.tar.gz --no-check-certificate
--2022-07-15 13:45:00--  https://dlcdn.apache.org/tomcat/tomcat-10/v10.0.22/bin/apache-tomcat-10.0.22.tar.gz
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.
WARNING: cannot verify dlcdn.apache.org's certificate, issued by ‘/C=US/O=Let's Encrypt/CN=R3’:
  Issued certificate has expired.
HTTP request sent, awaiting response... 200 OK
Length: 11933879 (11M) [application/x-gzip]
Saving to: ‘apache-tomcat-10.0.22.tar.gz’

100%[=================================================================================================================================================================>] 11,933,879  --.-K/s   in 0.1s    

2022-07-15 13:45:00 (105 MB/s) - ‘apache-tomcat-10.0.22.tar.gz’ saved [11933879/11933879]

wget 명령어로 복사한 URL을 통해 다운로드 한다. 필자의 경우에 certificate has expired 오류가 나서
--no-check-certicate 옵션을 넣어 다운로드를 완료하였다.
wget 명령어 대신에 tar.gz 파일 다운로드 후 파일질라와 같은 FTP툴을 이용해 서버로 업로드해도 상관없다.

 

  • Apache Tomcat 다운로드 및 압축 해제
# 파일 다운로드 확인
$ ls -al | grep tomcat
-rw-r--r--.   1 root root 11933879 Jun  3 02:03 apache-tomcat-10.0.22.tar.gz

 

# 압축 해제
$ tar -xzvf apache-tomcat-10.0.22.tar.gz

 

# 압축 해제 디렉토리 확인
$ ls -al | grep tomcat
drwxr-xr-x.   9 root root     4096 Jul 15 13:56 apache-tomcat-10.0.22
-rw-r--r--.   1 root root 11933879 Jun  3 02:03 apache-tomcat-10.0.22.tar.gz

# 디렉토리 이름 변경
$ mv apache-tomcat-10.0.22 tomcat10

 

  • Apache Tomcat 구동
# 디렉토리 이동
$ cd /usr/share/tomcat10/bin

# 톰캣 실행
$ ./startup.sh

 

  • Apache Tomcat 로그 확인
# 로그 디렉토리 이동
$ cd /usr/share/tomcat10/logs

# 톰캣 로그 열기
$ vi catalina.out

# 톰캣 로그 실시간 출력
$ tail -f catalina.out

 

  • Apache Tomcat 구동 확인
# 포트 확인
$ netstat -ant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp6       0      0 :::8080                 :::*                    LISTEN    

# 톰캣 프로세스 확인
$ ps -ef | grep tomcat
root      4054     1  4 14:24 pts/0    00:00:04 //bin/java -Djava.util.logging.config.file=/usr/share/tomcat10/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dignore.endorsed.dirs= -classpath /usr/share/tomcat10/bin/bootstrap.jar:/usr/share/tomcat10/bin/tomcat-juli.jar -Dcatalina.base=/usr/share/tomcat10 -Dcatalina.home=/usr/share/tomcat10 -Djava.io.tmpdir=/usr/share/tomcat10/temp org.apache.catalina.startup.Bootstrap start

 

  • 외부에서 접근 불가 시 방화벽 확인
# 방화벽 확인
$ cat /etc/firewalld/zones/public.xml
<?xml version="1.0" encoding="utf-8"?>
<zone>
  <short>Public</short>
  <description>For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description>
  <service name="dhcpv6-client"/>
  <service name="ssh"/>
  <port protocol="tcp" port="22"/>
  <port protocol="tcp" port="80"/>
</zone>

# 방화벽 8080 포트 정책 추가
$ firewall-cmd --permanent --zone=public --add-port=8080/tcp

# 방화벽 재구동
$ firewall-cmd --reload

 

Apache Tocmat/10.0.22

728x90

댓글