Install tomcat in Ubuntu

Introduction

Apache Tomcat is an Open Source Application that implements java Servlet, JSP(java Server Page) is used to deploy web application in the servlet container. Catalina┬áis┬áTomcat’s┬áservlet┬ácontainer.┬áContainer┬áManage┬ásecurity┬áas┬ádescribed┬áin┬áthe┬áServlet┬áSpecification.

Prerequisites

  1. One user account who has sudo access.
  2. JRE must be installed and JAVA_HOME variable must be set into environment.
    (If you don’t have JDK/JRE installed in you system you can find the steps here ).

Installation

Install Apache tomcat on Ubuntu

Step 1. Download the tar.gz file from Download page

OR

$ wget http://www-us.apache.org/dist/tomcat/tomcat-9/v9.0.30/bin/apache-tomcat-9.0.30.tar.gz

Step 2. Goto to the directory where you want to install tomcat. I have installed it in “/etc/opt/ ”

$ sudo cd /etc/opt

Step 3. Extract the tar

$ sudo tar -xvzf ~/Downloads/apache-tomcat-9.0.30.tar.gz

Step 4. Rename the folder to tomcat only.

$ sudo mv apache-tomcat-9.0.30 tomcat

Step 5. Give permission for executing startup.sh and shutdown.sh

$ chmod +x etc/opt/tomcat/bin/*

Step 5. Now set environment variable CATALINA_HOME

$ sudo vi /etc/environment

Press E for edit and add the tomcat installed path to the environment /opt/tomcat
To take effect you need to refresh the environment.

$ sudo source /etc/environment

Now check the CATALINA_HOME path

$ echo $CATALINA_HOME


If CATALINA_HOME is not showing the path redo the above steps.

Step 7. Now Start Tomcat

$ sudo CATALINA_HOME/bin/startup.sh

Step 8: Default port of Tomcat is 8080. If you want you can change the default port of tomcat in config. Now go to the browser and type this URL localhost:8080

Stopping tomcat

$ sudo CATALINA_HOME/bin/shutdown.sh

Congratulations you have successfully installed Tomcat in your system. Now you can deploy your Web Apps in tomcat.

To change the default configuration of tomcat read here. Change Tomcat default port in Ubuntu

Thank You

Leave a Reply