This article is outdated and may not work correctly for current operating systems or software.
This guide explains how to install Apache Tomcat on an Ubuntu 16.04 server.
Make sure that you have the latest stable version of Ubuntu 16.04.
sudo apt-get update
sudo apt-get install default-jdk
Find the directory for
update-alternatives --config java
Copy the directory, and then type the following.
This will open up the file that contains environment variables.
The path in quotes is the path that you are using.
Save and close the file.
Reload the environment variables so that they take effect.
Check to make sure that it worked:
You will see the path you've entered.
We will call this user 'tomcat', but you can use any name for this user.
groupadd tomcat useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat
Make sure that you know the version of Tomcat that you want to install.
For this tutorial, we will use version
8.5.24, and the download link is as follows.
Remember to choose the download with a
Make a directory for the Tomcat files.
cd wget your-tomcat-link
Unzip the files into the tomcat folder.
tar xvf apache-tomcat-8*tar.gz -C /opt/tomcat --strip-components=1
You can press the "
Tab" key after typing
apache, since you only have one download in your folder.
Make sure that the folders have the correct permissions.
cd /opt/ sudo chown -R tomcat tomcat/
JAVA_HOME path again, so that you can copy it.
Copy and paste the settings below into the
tomcat.service file you have just created. Edit the
JAVA_HOME path to the one that you copied. After this, save and close the file.
[Unit] Description=Apache Tomcat Web Application Container After=network.target [Service] Type=forking Environment=JAVA_HOME=/usr/lib/jvm/java-1.8.0-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=10 Restart=always [Install] WantedBy=multi-user.target
Reload the SystemD daemon so that the service settings that were added are included.
sudo systemctl daemon-reload
Start the Tomcat service.
sudo systemctl start tomcat
Check the status of your Tomcat server.
sudo systemctl status tomcat
You will see the Tomcat server landing page.