Phone :  +370 (5) 204-1903
Email: sales@1gbits.com
  1. Dedicated server
  2. Blog
  3. How To Install Apache Tomcat 8 on Ubuntu 16.04
How To Install Apache Tomcat 8 on Ubuntu 16.04


Sep, 16

Tomcat is an application server from the Apache Software Foundation that executes Java servlets and renders Web pages that include Java Server Page coding. Described as a "reference implementation" of the Java Servlet and the Java Server Page specifications, Tomcat is the result of an open collaboration of developers and is available from the Apache Web site in both binary and source versions. Tomcat can be used as either a standalone product with its own internal Web server or together with other Web servers, including Apache, Netscape Enterprise Server, Microsoft Internet Information Server (IIS), and Microsoft Personal Web Server. Tomcat requires a Java Runtime Enterprise Environment that confirms to JRE 1.1 or later.

Install Apache Tomcat 8 on Ubuntu 16.04

Installing Java (JRE or JDK). Once you have verified if Java is installed or not, choose the type of Java installation that you want with one of the following:

sudo apt-get install openjdk-7-jre
sudo apt-get install openjdk-7-jdk

Another alternative Java install is with Oracle JRE and JDK. However, we would need to install additional repositories for a proper installation:

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java

Then, you will need to fully update the system with the following command and install it:

sudo apt-get update
sudo apt-get install oracle-java8-installer

Verify Installed Java Version.

java -version


java version "1.8.0_74"
Java(TM) SE Runtime Environment (build 1.8.0_74-b02)
Java HotSpot(TM) 64-Bit Server VM (build 25.74-b02, mixed mode)

Setup JAVA_HOME on Ubuntu 16.04. Since many programs now-a-days need a JAVA_HOME environment variable to work properly. We will need to find the appropriate path to make these changes. With the following command, you can view your installations and their path:

sudo update-alternatives --config java
sudo nano /etc/profile

Now that you are in the user profile file, add the following code, along with the Path of your installation from the previous step, to the bottom. ( Example: JAVA_HOME=”YOUR_PATH”):

export JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk-"

Reload the file so all your changes could take effect with the following command:

source /etc/profile

Verify that your implementations are correct with the following command:

Configure Tomcat to run as a service.

You will get the following output.

You can verify the service running, by default tomcat runs on port no 8080.

Finally, open Tomcat from your browser, go to your IP or domain with the 8080 port (because Tomcat will always run on the 8080 port) as an example: mydomain.com:8080, replace mydomain.com with your IP or domain. To shutdown Tomcat you can simply run the shutdown script in the same folder like this:

Configure Tomcat users so they can access admin/manager sections. You can do this by adding the users in the conf/tomcat-users.xml file with your favorite text editor. Add this text to the file:

Place the following two lines just above the last line.

Save and close the file when you are finished. To put our changes into effect, restart the Tomcat service:

Save and close the file when you are finished. To put our changes into effect, restart the Tomcat service:

Congratulation’s! You have successfully installed Apache Tomcat. Save

author img


Leave A Comment