[CentOS7] tomcat 8 Binary install

[CentOS7] tomcat 8 Binary install

tomcat 8 Binary install 문서

tomcat Binary 파일은 https://archive.apache.org/dist/tomcat/ 에서 다운 받으실수 있습니다.

 

 

  • 차후 apache-tomcat 연동시 필요한 패키지를 설치 합니다.
[root@CentOS7 ~]# yum install -y httpd httpd-devel java-1.7.0-openjdk-devel

 

  • tomcat group 생성 및 user 를 생성 합니다.
[root@CentOS7 ~]# mkdir -p /opt/tomcat
[root@CentOS7 ~]# groupadd tomcat
[root@CentOS7 ~]# useradd -M -s /bin/nologin -g tomcat -d /opt/tomcat tomcat
[root@CentOS7 ~]# wget https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.38/bin/apache-tomcat-8.5.38.tar.gz
[root@CentOS7 ~]# tar xvf apache-tomcat-8.5.38.tar.gz -C /opt/tomcat --strip-components=1
[root@CentOS7 ~]# cd /opt/tomcat
[root@CentOS7 ~]# chgrp -R tomcat /opt/tomcat
[root@CentOS7 ~]# chmod -R g+r conf
[root@CentOS7 ~]# chmod g+x conf
[root@CentOS7 tomcat]# chown -R tomcat webapps/ work/ temp/ logs/

 

  • systemd 파일 생성합니다.
[root@CentOS7 tomcat]# vi /etc/systemd/system/tomcat.service
# Systemd unit file for tomcat
[Unit]
Description=Apache Tomcat Web Application Container
After=syslog.target network.target

[Service]
Type=forking

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

ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/bin/kill -15 $MAINPID

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

[Install]
WantedBy=multi-user.target

 

  • daemon-reload 및 tomcat 데몬을 실행 합니다.
[root@CentOS7 tomcat]# systemctl daemon-reload
[root@CentOS7 tomcat]# systemctl enable tomcat
[root@CentOS7 tomcat]# systemctl start tomcat

[root@CentOS7 tomcat]# systemctl status tomcat
● tomcat.service - Apache Tomcat Web Application Container
Loaded: loaded (/etc/systemd/system/tomcat.service; disabled; vendor preset: disabled)
Active: active (running) since Mon 2019-02-18 07:05:59 KST; 15s ago
Process: 1879 ExecStart=/opt/tomcat/bin/startup.sh (code=exited, status=0/SUCCESS)
Main PID: 1887 (catalina.sh)
CGroup: /system.slice/tomcat.service
├─1887 /bin/sh /opt/tomcat/bin/catalina.sh start
└─1888 java -Djava.util.logging.config.file=/opt/tomcat/conf/logging.properties -Djava.util.logging.ma...

Feb 18 07:05:59 CentOS7 systemd[1]: Starting Apache Tomcat Web Application Container...
Feb 18 07:05:59 CentOS7 systemd[1]: Started Apache Tomcat Web Application Container.
[root@CentOS7 tomcat]#

 

  • web-site 확인
  • http://192.168.0.10:8080/
[root@CentOS7 ~]# firewall-cmd --permanent --add-port=8080/tcp
[root@CentOS7 ~]# firewall-cmd --reload

 

 

  • tomcat-users.xml 파일 설정
  • admin user 와 password 를 지정 합니다.
[root@CentOS7 tomcat]# vi /opt/tomcat/conf/tomcat-users.xml
# line 추가
<user username="admin" password="password" roles="manager-gui,admin-gui"/>

 

  • 특정 아이피 대역에서만 접속 설정
[root@CentOS7 ~]# vi /opt/tomcat/webapps/manager/META-INF/context.xml
  <Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1|192.168.0.1" />

[root@CentOS7 ~]# systemctl restart tomcat

 

  • http://192.168.0.10:8080/manager/html 접속 확인
  • admin / password 를 입력합니다.

 

댓글 남기기