DigitalOcean VPS: Install Tomcat 8 on CentOS Step 3

Follow me

Tomorn Wongtibet

System Analyst at MitrPhol Sugar
ถนัดเขียนเรื่องราวแหล่งท่องเที่ยวและเทคนิคการพัฒนาระบบงานด้วยไอที
Follow me

Reference 1 : https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-8-on-centos-7
Reference 2 : http://www.vwin.co.th/linux/basic-commands/
Reference 3 : http://www.yougetsignal.com/tools/open-ports/
Reference 4 : http://stackoverflow.com/questions/24756240/how-can-i-use-iptables-on-centos-7

 

Create Tomcat User

  1. command: sudo groupadd tomcat
  2. command: sudo useradd -M -s /bin/nologin -g tomcat -d /opt/tomcat tomcatinstall tomcat 001

Install Tomcat

  1. Download Tomcat: http://tomcat.apache.org/download-80.cgi
  2. copy url path “tar.gz”install tomcat 002
  3. command: wget http://www.us.apache.org/dist/tomcat/tomcat-8/v8.0.30/bin/apache-tomcat-8.0.30.tar.gzinstall tomcat 003
  4. command: sudo mkdir /opt/tomcat
  5. command: sudo tar xvf apache-tomcat-8*tar.gz -C /opt/tomcat —strip-components=1install tomcat 004

Update permission

  1. command: cd /opt/tomcat
  2. command: sudo chgrp -R tomcat conf
  3. command: sudo chmod g+rwx conf
  4. command: sudo chmod g+r conf/*
  5. command: sudo chown -R tomcat webapps/ work/ temp/ logs/install tomcat 005

Install Systemd Unit File

  1. command: sudo nano /etc/systemd/system/tomcat.service
  2. copy script:
    # 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=-Xms256M -Xmx512M -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
    
    [Install]
    WantedBy=multi-user.target

    install tomcat 006

  3. command: sudo systemctl daemon-reload
  4. command: sudo systemctl start tomcat
  5. command: sudo systemctl enable tomcat
  6. test web port 8080install tomcat 008

Modify Tomcat User

  1. command: sudo nano /opt/tomcat/conf/tomcat-users.xmlconfig user tomcat
  2. add username and password of tomcat
  3. Exit: Ctrl+X
  4. Save: y
  5. Close: Enter
  6. command: service tomcat restart
  7. test connect tomcat page managerinstall tomcat 010

Tomcat Routing Port 80 to 8080

  1. command: systemctl stop firewalld
  2. command: systemctl mask firewalld
  3. command: yum install iptables-services
  4. command: systemctl enable iptables
  5. option clear tables command: iptables -F
  6. command: iptables -A PREROUTING -t nat -p tcp –dport 80 -j DNAT –to xxx.xxx.xxx.xxx:8080install tomcat 011
  7. command: service iptables save
  8. option restart tomcat command: service tomcat restart
  9. test connect port 80install tomcat 012

How to use SFTP

  1. download FileZilla FTP client
  2. connect VPS by user ‘root’ and ‘root’ password on port 22sftp centos 001

แสดงความเห็นด้วยบัญชีเฟสบุ๊ค