Install Tomcat 9 on an Ubuntu 16.04 VPS
Apache Tomcat (previously known as Jakarta Tomcat) or simply Tomcat, is an open source web server and servlet container developed by the Apache Software Foundation. It executes Java servlets and renders Web pages that include Java Server Page coding and it is one of the most popular web servers used by the java developers.
In this article we will install the latest release of Tomcat 9 server on an Ubuntu 16.04 VPS. This tutorial should work on other Debian based systems as well but was tested and written for Ubuntu 16.04
First of all login to your Ubuntu 16.04 VPS via SSH as user root
ssh [email protected]_address
and start a new screen session
screen -U -S tomcat9
To update all packages installed on your server run the following command in the terminal
apt-get update && apt-get upgrade
In order to run Tomcat server, Java has to be installed on the VPS. Execute the following command to install the Java Development Kit package (JDK)
apt-get install default-jdk
After the installation is completed, You can check the Java installed on your server using the command below
If you receive an output similar to the one above, the installation is successful.
openjdk version "1.8.0_91" OpenJDK Runtime Environment (build 1.8.0_91-8u91-b14-0ubuntu4~16.04.1-b14) OpenJDK 64-Bit Server VM (build 25.91-b14, mixed mode)
Once Java is installed on the server, we will proceed installing Tomcat 9.
For security reasons it is not recommended to run Tomcat as user root, so we will create a new system user
useradd -r tomcat9 --shell /bin/false
Change the current working directory to /opt and download the latest Tomcat 9 release to the /opt directory on your server. At the moment of writing this tutorial Tomcat version 9.0.0.M6 is the latest one. You should go to Tomcat’s official website and check if a newer version is available.
cd /opt wget http://mirror.symnds.com/software/Apache/tomcat/tomcat-9/v9.0.0.M9/bin/apache-tomcat-9.0.0.M9.tar.gz
Extract the content of the ‘apache-tomcat-9.0.0.M6.tar.gz’ tarball archive
tar -zxf apache-tomcat-9.0.0.M6.tar.gz
Create a symbolic link of the Tomcat directory to /opt/tomcat-latest and set the appropriate ownership:
ln -s apache-tomcat-9.0.0.M6 tomcat-latest chown -hR tomcat9: tomcat-latest apache-tomcat-9.0.0.M6
Tomcat can be started, stopped and restarted using the bash scripts located in the /opt/tomcat-latest/bin directory or even better, we will create a systemd init file for that purpose
and add the following content to the file
[Unit] Description=Tomcat9 After=network.target [Service] Type=forking User=tomcat9 Group=tomcat9 Environment=CATALINA_PID=/opt/tomcat-latest/tomcat9.pid Environment=JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64 Environment=CATALINA_HOME=/opt/tomcat-latest Environment=CATALINA_BASE=/opt/tomcat-latest Environment="CATALINA_OPTS=-Xms512m -Xmx512m" Environment="JAVA_OPTS=-Dfile.encoding=UTF-8 -Dnet.sf.ehcache.skipUpdateCheck=true -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:+UseParNewGC" ExecStart=/opt/tomcat-latest/bin/startup.sh ExecStop=/opt/tomcat-latest/bin/shutdown.sh [Install] WantedBy=multi-user.target
Save the file, reload the systemd daemon, start the Tomcat server and enable it to start on boot
systemctl daemon-reload systemctl start tomcat systemctl enable tomcat
Finally, if you closely followed the instructions in this tutorial you will be able to access Tomcat by navigating your favorite web browser to
Of course you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to install Tomcat 9 for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.