Skip to content

Instantly share code, notes, and snippets.

@Clivern
Last active January 7, 2020 01:07
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 21 You must be signed in to fork a gist
  • Save Clivern/b7ecd618969c06e31d5792b8868a2bce to your computer and use it in GitHub Desktop.
Save Clivern/b7ecd618969c06e31d5792b8868a2bce to your computer and use it in GitHub Desktop.
How to Install Apache Tomcat 8 on Ubuntu 16.04
#!/bin/bash
# For More Info http://clivern.com/how-to-install-apache-tomcat-8-on-ubuntu-16-04
sudo apt-get update
sudo apt-get install default-jdk
sudo apt-get install unzip
cd /opt
curl -O http://apache.mirrors.ionfish.org/tomcat/tomcat-8/v8.5.15/bin/apache-tomcat-8.5.15.zip
sudo unzip apache-tomcat-8.5.15.zip
sudo mv apache-tomcat-8.5.15 tomcat
sudo groupadd tomcat
sudo useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat
sudo chgrp -R tomcat /opt/tomcat
sudo chown -R tomcat /opt/tomcat
sudo chmod -R 755 /opt/tomcat
sudo echo "[Unit]
Description=Apache Tomcat Web Server
After=network.target
[Service]
Type=forking
Environment=JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/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=/opt/tomcat/bin/shutdown.sh
User=tomcat
Group=tomcat
UMask=0007
RestartSec=15
Restart=always
[Install]
WantedBy=multi-user.target" > /etc/systemd/system/tomcat.service
sudo ufw allow 8080
sudo systemctl daemon-reload
sudo systemctl start tomcat
sudo systemctl status tomcat
@rferreiraperez
Copy link

you can find tomcat available versions in:
http://apache.mirrors.ionfish.org/tomcat/tomcat-8/
today the last version is 8.5.20 so you can use this link to install tomcat:
http://apache.mirrors.ionfish.org/tomcat/tomcat-8/v8.5.20/bin/apache-tomcat-8.5.20.zip

the script works perfectly!

@Lieuvodinh
Copy link

hello,
I use google cloud VPS and I don't setup anything yet. I follow your tutorial step by step, but still can't access http://my_IP:8080
Pls tell me do I need install apache2 or any thing else?
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment