728x90
반응형
Tomcat 설치 
  • 다운로드 사이트

https://tomcat.apache.org/download-10.cgi

 

Apache Tomcat® - Apache Tomcat 10 Software Downloads

Welcome to the Apache Tomcat® 10.x software download page. This page provides download links for obtaining the latest version of Tomcat 10.1.x software, as well as links to the archives of older releases. Unsure which version you need? Specification versi

tomcat.apache.org

# wget https://dlcdn.apache.org/tomcat/tomcat-10/v10.1.19/bin/apache-tomcat-10.1.19.tar.gz

# tar -xvf apache-tomcat-10.1.19.tar.gz

# mv /root/apache-tomcat-10.1.19 /root/tomcat

# /root/tomcat/bin/./start.sh   --> 8080 포트 LISTEN 확인

# netstat -ntpa |grep 8080
tcp6       0      0 :::8080                 :::*                    LISTEN      9743/java

 

  • 웹페이지 접속확인(default page) 

  • Server Status, Manager App, Host Manager 기능은 보안 문제로 기본적으로 막혀 있음, 접속시 403 Access Denied 해결
  • 중단부분에 Tomcat Setup, JDBC DataSources 등 doc, sample 등도 클릭하면 403 Access Denied 

 

# 1. conf 디렉토리 tomcat-users.xms 설정 변경

# vi /root/tomcat/conf/tomcat-users.xml 

  - 제일 아래 username / password 도 admin/amdin 으로 변경함



<tomcat-users xmlns="http://tomcat.apache.org/xml"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
              version="1.0">

<role rolename="admin"/>
<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<role rolename="manager"/>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<user username="admin" password="admin" roles="admin,manager,admin-gui,admin-script,manager-gui,manager-script,manager-jmx,manager-status" />

 

# 2. /root/tomcat/webapp/아래 context.xml  설정 변경

# ls /root/tomcat/webapps/
context.xml  docs  examples  host-manager  manager  ROOT  SampleWebApp  SampleWebApp.war

# /root/tomcat/webapps/ 아래 context.xml 파일을 찾아서 다 바꿔줘야 됨

# find . -name context.xml
./docs/META-INF/context.xml
./examples/META-INF/context.xml
./host-manager/META-INF/context.xml
./manager/META-INF/context.xml
./SampleWebApp/META-INF/context.xml
./context.xml


# tree docs
docs
└── META-INF
    └── context.xml
    
exaples
└── META-INF
    └── context.xml
    
host-manager
└── META-INF
    └── context.xml
    
manager
└── META-INF
    └── context.xml

SampleWebApp
└── META-INF
    └── context.xml
  • 변경 예 
# vi /root/tomcat/webapps/manager/META-INF/context.xml

<?xml version="1.0" encoding="UTF-8"?>

<Context antiResourceLocking="false" privileged="true" >
  <CookieProcessor className="org.apache.tomcat.util.http.Rfc6265CookieProcessor"
                   sameSiteCookies="strict" />
  <Valve className="org.apache.catalina.valves.RemoteAddrValve"
#------>   allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
  <Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
</Context>

# allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" /> 를
# allow=".*" /> 으로 변경

 

# 3. Tomcat 재기동후  접속확인 (8080 포트가 정상적으로 올라왔는지 확인)

# /root/tomcat/bin/./shutdown.sh
Using CATALINA_BASE:   /root/tomcat
Using CATALINA_HOME:   /root/tomcat
Using CATALINA_TMPDIR: /root/tomcat/temp
Using JRE_HOME:        /usr/lib/jvm/java-17-openjdk-17.0.1.0.12-2.el8_5.x86_64
Using CLASSPATH:       /root/tomcat/bin/bootstrap.jar:/root/tomcat/bin/tomcat-juli.jar
Using CATALINA_OPTS:    -javaagent:/root/tomcat/jmx_exporter/jmx_prometheus_javaagent-0.17.0.jar=8081:/root/tomcat/jmx_exporter/config.yaml

# /root/tomcat/bin/./startup.sh
Using CATALINA_BASE:   /root/tomcat
Using CATALINA_HOME:   /root/tomcat
Using CATALINA_TMPDIR: /root/tomcat/temp
Using JRE_HOME:        /usr/lib/jvm/java-17-openjdk-17.0.1.0.12-2.el8_5.x86_64
Using CLASSPATH:       /root/tomcat/bin/bootstrap.jar:/root/tomcat/bin/tomcat-juli.jar
Using CATALINA_OPTS:    -javaagent:/root/tomcat/jmx_exporter/jmx_prometheus_javaagent-0.17.0.jar=8081:/root/tomcat/jmx_exporter/config.yaml
Tomcat started.

# netstat -ntpa |grep LISTEN
tcp6       0      0 127.0.0.1:8005          :::*                    LISTEN      12226/java
tcp6       0      0 :::8080                 :::*                    LISTEN      12226/java
tcp6       0      0 :::8081                 :::*                    LISTEN      12226/java

 

  • Server Status

  • Manager App

  • Host Manager 

728x90
반응형
LIST

'programming > java' 카테고리의 다른 글

JAVA Version 업그레이드  (0) 2024.02.29
728x90
반응형

 

CentOS8에서 자바 버전 1.11 에서 1.17로 변경

 

1. 현재 자바 버젼 확인

# java -version
openjdk version "11.0.13" 2021-10-19 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.13+8-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.13+8-LTS, mixed mode, sharing)

 

2. 설치 가능한 java 버젼 확인

# yum list java*jdk-devel
Last metadata expiration check: 1:45:54 ago on Thu 29 Feb 2024 05:22:45 PM KST.
Installed Packages
java-11-openjdk-devel.x86_64                                                            1:11.0.13.0.8-4.el8_5                                                           @appstream
Available Packages
java-1.8.0-openjdk-devel.x86_64                                                         1:1.8.0.312.b07-2.el8_5                                                         appstream
java-17-openjdk-devel.x86_64                                                            1:17.0.1.0.12-2.el8_5                                                           appstream

 

3. 원하는 버젼 설치

# yum install -y java-17-openjdk-devel.x86_64
Last metadata expiration check: 1:47:33 ago on Thu 29 Feb 2024 05:22:45 PM KST.
Dependencies resolved.
==================================================================================================================================================================================
 Package                                            Architecture                     Version                                            Repository                           Size
==================================================================================================================================================================================
Installing:
 java-17-openjdk-devel                              x86_64                           1:17.0.1.0.12-2.el8_5                              appstream                           5.1 M
Installing dependencies:
 java-17-openjdk                                    x86_64                           1:17.0.1.0.12-2.el8_5                              appstream                           244 k
 java-17-openjdk-headless                           x86_64                           1:17.0.1.0.12-2.el8_5                              appstream                            41 M

Transaction Summary
==================================================================================================================================================================================
Install  3 Packages

..
..
..
Installed:
  java-17-openjdk-1:17.0.1.0.12-2.el8_5.x86_64          java-17-openjdk-devel-1:17.0.1.0.12-2.el8_5.x86_64          java-17-openjdk-headless-1:17.0.1.0.12-2.el8_5.x86_64

Complete!

 

4. Default Java 변경하기

# /usr/sbin/alternatives --config java

There are 2 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*+ 1           java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-11.0.13.0.8-4.el8_5.x86_64/bin/java)
   2           java-17-openjdk.x86_64 (/usr/lib/jvm/java-17-openjdk-17.0.1.0.12-2.el8_5.x86_64/bin/java)

Enter to keep the current selection[+], or type selection number: 2

 

5. 환경변수 재설정

# java -version
openjdk version "11.0.13" 2021-10-19 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.13+8-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.13+8-LTS, mixed mode, sharing)

# echo $JAVA_HOME
/usr/bin/javac

# vi /etc/profile
--> 삭제 JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.275.b01-0.el7_9.i386
JAVA_HOME=/usr/lib/jvm/java-17-openjdk-17.0.1.0.12-2.el8_5.x86_64
export JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin
export PATH

 

6. 자바 버젼 확인

# su - root
Last login: Thu Feb 29 19:44:10 KST 2024 on pts/0

# echo $JAVA_HOME
/usr/lib/jvm/java-17-openjdk-17.0.1.0.12-2.el8_5.x86_64

# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/lib/jvm/java-17-openjdk-17.0.1.0.12-2.el8_5.x86_64/bin:/root/bin

# java -version
openjdk version "17.0.1" 2021-10-19 LTS
OpenJDK Runtime Environment 21.9 (build 17.0.1+12-LTS)
OpenJDK 64-Bit Server VM 21.9 (build 17.0.1+12-LTS, mixed mode, sharing)
728x90
반응형
LIST

'programming > java' 카테고리의 다른 글

Tomcat 설치 및 Manager 설정(403 Access Denied)  (0) 2024.03.01

+ Recent posts