DigitalOcean VPS: Install Tomcat 8 on CentOS Step 3

Follow me

Tomorn Wongtibet

System Analyst at MitrPhol Sugar
Follow me

Reference 1 :
Reference 2 :
Reference 3 :
Reference 4 :


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:
  2. copy url path “tar.gz”install tomcat 002
  3. command: wget 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
    Description=Apache Tomcat Web Application Container
    Environment='CATALINA_OPTS=-Xms256M -Xmx512M -server -XX:+UseParallelGC'
    ExecStop=/bin/kill -15 $MAINPID

    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 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