OS

2022.02.16 14:16

[CentOS 7] JDK-1.8.0 & apache-tomcat-8.5.61

  • 비아웹 오래 전 2022.02.16 14:16 인기
  • 6,416
    0

설치환경

OS : CentOS Linux release 7.8.2003 (Core)

SELINUX : disabled

테스트일자 : 2021-01-29

 

1. JDK 1.8.0 설치

[root@localhost ~]# yum install -y java-1.8.0-openjdk-devel

2. 환경변수 설정

[root@localhost ~]# readlink -f /bin/javac /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.282.b08-1.el7_9.x86_64/bin/javac [root@localhost ~]# vi /etc/profile
-- vi /etc/profile -
-(맨아래 부분 추가) # JAVA_HOMEexportJAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.282.b08-1.el7_9.x86_64 -- vi /etc/profile --
 
[root@localhost ~]# source /etc/profile [root@localhost ~]# echo $JAVA_HOME/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.282.b08-1.el7_9.x86_64

3. Apache-Tomcat 설치

[root@localhost ~]# cd /opt/
[root@localhost ~]# wget https://downloads.apache.org/tomcat/tomcat-8/v8.5.61/bin/apache-tomcat-8.5.61.tar.gz
(필요 시 "yum -y install wget" 설치)
[root@localhost ~]# tar xzf apache-tomcat-8.5.61.tar.gz
[root@localhost ~]# mv apache-tomcat-8.5.61/usr/

4. 환경변수 설정

[root@localhost ~]# vi /etc/profile
-- vi /etc/profile --(JAVA_HOME 아래부분 추가) # JAVA_HOMEexportJAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.282.b08-1.el7_9.x86_64 # tomcat exportexportCATALINA_HOME=/usr/apache-tomcat-8.5.61
-- vi /etc/profile --
 
[root@localhost ~]# source /etc/profile

5. 톰캣 환경설정

[root@localhost ~]# vi /usr/apache-tomcat-8.5.61/conf/server.xml -69번라인 포트설정,70번라인 URIEncoding="UTF-8" 추가
-- vi /usr/apache-tomcat-8.5.61/conf/server.xml --

69 <Connector port="8080" protocol="HTTP/1.1"
70 URIEncoding="UTF-8"
71 connectionTimeout="20000"
72 redirectPort="8443"/>
-- vi /usr/apache-tomcat-8.5.61/conf/server.xml --

6. 톰캣 실행 및 테스트

※ 실행 [root@localhost ~]# /usr/apache-tomcat-8.5.61/bin/startup.sh Using CATALINA_BASE:/usr/apache-tomcat-8.5.61 Using CATALINA_HOME:/usr/apache-tomcat-8.5.61 Using CATALINA_TMPDIR:/usr/apache-tomcat-8.5.61/temp Using JRE_HOME:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.282.b08-1.el7_9.x86_64 Using CLASSPATH:/usr/apache-tomcat-8.5.61/bin/bootstrap.jar:/usr/apache-tomcat-8.5.61/bin/tomcat-juli.jar Using CATALINA_OPTS: Tomcat started.
※ 포트확인 [root@localhost ~]# netstat -nltp Active Internet connections(only servers)Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 000.0.0.0:220.0.0.0:*LISTEN896/sshd tcp 00127.0.0.1:250.0.0.0:*LISTEN1023/master tcp6 00:::8080:::*LISTEN1406/java tcp6 00:::22:::*LISTEN896/sshd tcp6 00::1:25:::*LISTEN1023/master tcp6 00127.0.0.1:8005:::*LISTEN1406/java
8080포트 오픈 후 URL 확인 [root@localhost ~]# iptables -F 또는 iptables -IINPUT-p tcp --dport 8080-j ACCEPT http://IP주소:8080
 
※ 종료 [root@localhost ~]# /usr/apache-tomcat-8.5.61/bin/catalina.sh stop Using CATALINA_BASE:/usr/apache-tomcat-8.5.61 Using CATALINA_HOME:/usr/apache-tomcat-8.5.61 Using CATALINA_TMPDIR:/usr/apache-tomcat-8.5.61/temp Using JRE_HOME:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.282.b08-1.el7_9.x86_64 Using CLASSPATH:/usr/apache-tomcat-8.5.61/bin/bootstrap.jar:/usr/apache-tomcat-8.5.61/bin/tomcat-juli.jar Using CATALINA_OPTS:

7. 톰캣 서비스 등록

[root@localhost ~]# vi /usr/lib/systemd/system/tomcat.service
(아래 내용 복사,붙여놓기)
-- vi /usr/lib/systemd/system/tomcat.service --
[Unit] Description=tomcat8 After=network.target syslog.target
[Service] Type=forking #Environment=JAVA_HOME=/usr/java/jdk1.8.0_191 Environment=JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.282.b08-1.el7_9.x86_64 User=root Group=root #ExecStart=/usr/apache-tomcat-8.5.37/bin/startup.sh #ExecStop=/usr/apache-tomcat-8.5.37/bin/shutdown.sh ExecStart=/usr/apache-tomcat-8.5.61/bin/startup.sh ExecStop=/usr/apache-tomcat-8.5.61/bin/shutdown.sh UMask=0007 RestartSec=10 Restart=always SuccessExitStatus=143
 
[Install] WantedBy=multi-user.target
-- vi /usr/lib/systemd/system/tomcat.service --

[root@localhost ~]# systemctl enable tomcat.service [root@localhost ~]# systemctl start tomcat.service

감사합니다.

비아웹

  • 공유링크 복사
  • 이전글vsftpd passive mode 설정2022.02.16
  • 다음글Minicom 설치 및 사용법2022.02.16
  • 댓글목록

    등록된 댓글이 없습니다.