티스토리 뷰

OS/Linux

Ubuntu 18.04 : Tomcat 설치

파란크리스마스 2018. 10. 8. 03:11
728x90

출처

Tomcat 8.5 다운로드 및 압축해제

$ wget http://apache.tt.co.kr/tomcat/tomcat-8/v8.5.34/bin/apache-tomcat-8.5.34.tar.gz
$ tar xvf apache-tomcat-8.5.34.tar.gz
$ sudo mv apache-tomcat-8.5.34 /usr/local/

jdk 설치

$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java8-installer

서비스 파일 작성

$ sudo vi /etc/systemd/system/tomcat.service

[Unit]
Description=Apache Tomcat Web Application Container
After=network.target

[Service]
Type=forking

Environment=JAVA_HOME=/usr/lib/jvm/java-8-oracle
Environment=CATALINA_PID=/usr/local/apache-tomcat-8.5.34/temp/tomcat.pid
Environment=CATALINA_HOME=/usr/local/apache-tomcat-8.5.34
Environment=CATALINA_BASE=/usr/local/apache-tomcat-8.5.34
Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'
Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'

ExecStart=/usr/local/apache-tomcat-8.5.34/bin/startup.sh
ExecStop=/usr/local/apache-tomcat-8.5.34/bin/shutdown.sh

User=tomcat
Group=tomcat
UMask=0007
RestartSec=10
Restart=always

[Install]
WantedBy=multi-user.target

Tomcat 8.5 서비스 등록

$ sudo systemctl daemon-reload
$ sudo systemctl enable tomcat      (재부팅시 자동실행)
Created symlink from /etc/systemd/system/multi-user.target.wants/tomcat.service to /etc/systemd/system/tomcat.service.

Tomcat 8.5 서비스 실행

$ sudo systemctl start tomcat

Tomcat 8.5 서비스 실행 정보 확인

$ systemctl status tomcat.service
● tomcat.service - Apache Tomcat Web Application Container
   Loaded: loaded (/etc/systemd/system/tomcat.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2018-10-04 07:13:23 KST; 17s ago
  Process: 5797 ExecStart=/usr/local/apache-tomcat-8.5.34/bin/startup.sh (code=exited, status=0/SUCCESS)
 Main PID: 5805 (java)
    Tasks: 48 (limit: 4915)
   CGroup: /system.slice/tomcat.service
           └─5805 /usr/lib/jvm/java-8-oracle/bin/java -Djava.util.logging.config.file=/usr/local/apache-to
 
10월 04 07:13:23 bluesanta-ubuntu systemd[1]: Starting Apache Tomcat Web Application Container...
10월 04 07:13:23 bluesanta-ubuntu startup.sh[5797]: Using CATALINA_BASE:   /usr/local/apache-tomcat-8.5.34
10월 04 07:13:23 bluesanta-ubuntu startup.sh[5797]: Using CATALINA_HOME:   /usr/local/apache-tomcat-8.5.34
10월 04 07:13:23 bluesanta-ubuntu startup.sh[5797]: Using CATALINA_TMPDIR: /usr/local/apache-tomcat-8.5.34
10월 04 07:13:23 bluesanta-ubuntu startup.sh[5797]: Using JRE_HOME:        /usr/lib/jvm/java-8-oracle
10월 04 07:13:23 bluesanta-ubuntu startup.sh[5797]: Using CLASSPATH:       /usr/local/apache-tomcat-8.5.34
10월 04 07:13:23 bluesanta-ubuntu startup.sh[5797]: Using CATALINA_PID:    /usr/local/apache-tomcat-8.5.34
10월 04 07:13:23 bluesanta-ubuntu startup.sh[5797]: Tomcat started.
10월 04 07:13:23 bluesanta-ubuntu systemd[1]: Started Apache Tomcat Web Application Container.

Tomcat 8.5 서비스 종료

$ sudo systemctl stop tomcat

방화벽 설정

$ sudo iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
댓글
300x250
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/11   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
글 보관함