OS/Raspberry Pi

Raspberry Pi 4 : Tomcat 설치

파란크리스마스 2021. 10. 23. 22:14
728x90

출처

Tomcat 다운로드

pi@raspberrypi:~$ wget https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.72/bin/apache-tomcat-8.5.72.tar.gz

Tomcat 압축풀기

pi@raspberrypi:~$ sudo tar xvf apache-tomcat-8.5.72.tar.gz -C /usr/local
pi@raspberrypi:~$ cd /usr/local/apache-tomcat-8.5.72/
pi@raspberrypi:/usr/local/apache-tomcat-8.5.72$ 

Tomcat 서비스 등록

tomcat.service 파일 생성

pi@raspberrypi:~$ sudo vi /etc/systemd/system/tomcat.service

tomcat.service 파일

[UNIT]
Description=tomcat8
After=syslog.target network.target

[Service]
Type=forking

Environment="JAVA_HOME=/usr/local/java/jdk1.8.0_202/"
Environment="CATALINA_HOME=/usr/local/apache-tomcat-8.5.72"
Environment="CATALINA_BASE=/usr/local/apache-tomcat-8.5.72"
Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC"

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

User=root
Group=root
UMask=0007
RestartSec=10

[Install]
WantedBy=multi-user.target

Tomcat 서비스 등록

pi@raspberrypi:~$ sudo systemctl enable tomcat.service Created symlink /etc/systemd/system/multi-user.target.wants/tomcat.service → /etc/systemd/system/tomcat.service.

Tomcat 서비스 시작

pi@raspberrypi:~$ sudo systemctl start tomcat.service

Tomcat 서비스 종료

pi@raspberrypi:~$ sudo systemctl start tomcat.service

Tomcat 서비스 재시작

pi@raspberrypi:~$ sudo systemctl restart tomcat.service

Tomcat 서비스 싱태 확인

pi@raspberrypi:~$ sudo systemctl status tomcat.service
● tomcat.service
   Loaded: loaded (/etc/systemd/system/tomcat.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2021-10-23 22:32:44 KST; 8s ago
  Process: 18200 ExecStart=/usr/local/apache-tomcat-8.5.72/bin/startup.sh (code=exited, status=0/SUCCESS
 Main PID: 18207 (java)
    Tasks: 24 (limit: 4915)
   CGroup: /system.slice/tomcat.service
           └─18207 /usr/local/java/jdk1.8.0_202//bin/java -Djava.util.logging.config.file=/usr/local/apa
 
Oct 23 22:32:44 raspberrypi systemd[1]: Starting tomcat.service...
Oct 23 22:32:44 raspberrypi startup.sh[18200]: Tomcat started.
Oct 23 22:32:44 raspberrypi systemd[1]: Started tomcat.service.