• Home
  • Ubuntu 16.04
    • Whats New ?
    • Install JAVA 8
    • Setup LAMP Stack
    • Install LEMP Stack
    • Install Node.js
    • Install Git
    • Move Unity Launcher to Bottom
  • FeedBack
  • Funny Tools
  • Tutorials
    • Linux Distributions
      • CentOS
      • Debian
      • Fedora
      • LinuxMint
    • Monitoring Tools
      • Monit
      • Nagios
      • NRPE
    • Network Services
      • DHCP
      • DNS
      • FTP
    • Databases
      • MySQL
      • MariaDB
      • MongoDB
      • PostgreSQL
      • SQL Server
    • Amazon Web Services
  • Submit Article
  • About Us
TecAdmin.net
  • Home
  • Ubuntu 16.04
    • Whats New ?
    • Install JAVA 8
    • Setup LAMP Stack
    • Install LEMP Stack
    • Install Node.js
    • Install Git
    • Move Unity Launcher to Bottom
  • FeedBack
  • Funny Tools
  • Tutorials
    • Linux Distributions
      • CentOS
      • Debian
      • Fedora
      • LinuxMint
    • Monitoring Tools
      • Monit
      • Nagios
      • NRPE
    • Network Services
      • DHCP
      • DNS
      • FTP
    • Databases
      • MySQL
      • MariaDB
      • MongoDB
      • PostgreSQL
      • SQL Server
    • Amazon Web Services
  • Submit Article
  • About Us
07 December 2015

How to Install Apache Tomcat 9 on Ubuntu 18.04 / 16.04

Written by Rahul K. | December 7, 2015
Tomcat apache tomcat, Apache Tomcat 9, install tomcat on ubuntu, tomcat, Tomcat 9

Apache Tomcat is another product released by the Apache Software Foundation. It is an open source implementation of the Java Servlet and JavaServer Pages (JSP) technologies. Tomcat is a web server used for hosting the Java-based web application.

Apache Tomcat team has announced its latest Tomcat 9.0.6 release on Jan 18, 2018. This article helps you to Install Tomcat 9 on Ubuntu 18.04/16.04 systems.

Step 1 – Java Installation

You must have Java installed on the system before installing Apache Tomcat on a Linux VPS. Tomcat 9 required Java 8 or later version to work. You can check and verify that Java is installed with the right version.

java -version

java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)

If you don’t have Java installed on your system or installed a lower version, run below commands to satisfy requirements.

sudo apt-get update
sudo apt-get install default-jdk

Step 2 – Download Tomcat Archive

You need to download the Tomcat archive from its official download website or mirrors. Download Apache Tomcat 9 archive file using following commands or you can visit Tomcat 9 official download page for download most recent available version.

cd /usr/local
wget http://www-us.apache.org/dist/tomcat/tomcat-9/v9.0.6/bin/apache-tomcat-9.0.6.tar.gz
tar xzf apache-tomcat-9.0.6.tar.gz
mv apache-tomcat-9.0.6 apache-tomcat9

Step 3 – Configure Environment Variables

Now configure the required environment variables for the Tomcat. Set CATALINA_HOME to the extracted tomcat directory. Also set Java environment variables as per Java installed on your system.

echo "export CATALINA_HOME="/usr/local/apache-tomcat9"" >> ~/.bashrc
echo "export JAVA_HOME="/usr/lib/jvm/java-8-oracle"" >> ~/.bashrc
echo "export JRE_HOME="/usr/lib/jvm/java-8-oracle/jre"" >> ~/.bashrc
source ~/.bashrc

Step 4 – Setup Tomcat User Accounts

Finally we need to create user accounts to secure and access admin/manager pages. Edit conf/tomcat-users.xml file in your editor and paste inside <tomcat-users> </tomcat-users> tags.

<!-- user manager can access only manager section -->
<role rolename="manager-gui" />
<user username="manager" password="_SECRET_PASSWORD_" roles="manager-gui" />

<!-- user admin can access manager and admin section both -->
<role rolename="admin-gui" />
<user username="admin" password="_SECRET_PASSWORD_" roles="manager-gui,admin-gui" />

Step 5 – Enable Host/Manager for Remote IP

The default manager and host-manager web pages are enabled to access from localhost only. To access these pages from the remote system, you have to allow your IP or IP range in application-specific context.xml file.

Manager File: ./webapps/manager/META-INF/context.xml
Host Manager File: ./webapps/host-manager/META-INF/context.xml

Edit above files and add your IP address like the screenshot. After making changes restart Tomcat service.

Step 6 – Starting Tomcat Service

Tomcat is very easy to use, There is no need to compile its source. You simply extract the archive and start the tomcat server. Tomcat by default start on port 8080, So make sure no other application using the same port.

cd /usr/local/apache-tomcat9
chmod +x ./bin/startup.sh
./bin/startup.sh

[Sample Output]

Using CATALINA_BASE:   /usr/local/apache-tomcat9
Using CATALINA_HOME:   /usr/local/apache-tomcat9
Using CATALINA_TMPDIR: /usr/local/apache-tomcat9/temp
Using JRE_HOME:        /usr/lib/jvm/java-8-oracle/jre
Using CLASSPATH:       /usr/local/apache-tomcat9/bin/bootstrap.jar:/usr/local/apache-tomcat9/bin/tomcat-juli.jar
Tomcat started.

Step 7 – Access Tomcat in Browser

Tomcat server default works on port 8080. Access tomcat in the web browser by connecting your server on port 8080.

Access Tomcat Home- This is default home screen of tomcat 9. There are no authentication required to access this page..

http://localhost.com:8080 

Access Manager App- Click on Manager App link displayed on home page.This page is allowed for Admin and Manager access both.

http://example.com:8080/manager/html 

Access Host Manager Page:- Click on the Host Manager link on your Tomcat home.This page is allowed for Admin access only.

http://example.com:8080/host-manager/html 

Share it!
Share on Facebook
Share on Twitter
Share on Google+
Share on Reddit
Share on Tumblr
Rahul K.
Rahul K.
Connect on Facebook Connect on Twitter Connect on Google+

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

Related Posts

  • How to Install Apache Tomcat 9 on Debian 9/8

  • How to Change Tomcat default Port

  • How to Install Apache Tomcat 9 on CentOS/RHEL 7/6 and Fedora 27/26/25

  • How to Install Tomcat 7.0.82 Server on Ubuntu, Debian and LinuxMint

  • How to Install Tomcat 8.5 on CentOS, Ubuntu & LinuxMint

16 Comments

  1. vasso Reply to vasso
    February 1, 2018 at 9:14 pm

    Hello I stuck on step 6, When
    ./bin/startup.sh
    I get
    -bash: ./bin/startup.sh: Permission denied
    How can I solve this?

    • Rahul K. Rahul K. Reply to Rahul
      February 2, 2018 at 10:43 am

      Run this command to set execute permissions: (Also updated tutorial)

      chmod +x ./bin/startup.sh

      • vasso Reply to vasso
        February 9, 2018 at 11:47 am

        Tank you, it worked but I can’t access tomcat from the browser in step 7. I installed tommcat on a virtual server in my shool and I have access on it with openvpn. What can I do now?

        • Rahul K. Rahul K. Reply to Rahul
          February 9, 2018 at 11:59 am

          What is showing on screen?

          • vasso Reply to vasso
            February 9, 2018 at 3:04 pm

            It’s showing : Tomcat started and on the browser : the computer 192.168.6.54 refused connection

          • vasso Reply to vasso
            February 11, 2018 at 9:13 pm

            Which ip I must put on step 5?

            • Rahul K. Rahul K.
              February 12, 2018 at 4:19 am

              This is IP from where you need to access Host Manager dashboard. Generally, it will be your public IP, LAN IP or LAN network.

  2. Shiv Reply to Shiv
    November 4, 2017 at 11:50 pm

    Thanks

  3. Woodspring Reply to Woodspring
    September 4, 2017 at 3:08 pm

    Thank you. It is really good.

  4. willie Reply to willie
    August 1, 2017 at 8:20 pm

    Thank you very much!

  5. Toseef Reply to Toseef
    July 4, 2017 at 4:34 am

    You are awesome man!! I wasted a whole damn day to install tomcat 9, but this helps me in the end.

    Just one thing to add for new Ubuntu users: type this command in terminal to configure CATALINA_HOME environment variable;

    $ sudo su –

  6. boudjemaa Reply to boudjemaa
    January 23, 2017 at 3:42 pm

    thank you very much

  7. angela Reply to angela
    November 13, 2016 at 5:48 pm

    Hi
    thank you, thank you… thank you..very much : )

  8. Max Reply to Max
    September 16, 2016 at 1:43 pm

    Thanks it works for me

  9. Rob Krum Reply to Rob
    May 16, 2016 at 8:40 am

    Love the tutorial! Just curious how I would get Tomcat9 to startup on machine reboot though. Otherwise this tutorial worked wonders for me!

    • Rhys Reply to Rhys
      October 18, 2016 at 7:51 pm

      https://www.rosehosting.com/blog/install-tomcat-9-on-an-ubuntu-16-04-vps/

      tells you how to set it up for machine reboot

Leave a Reply

Cancel reply

Popular Posts

  • How to Install JAVA 8 on Ubuntu 16.04/14.04, LinuxMint 18/17
  • How to Install s3cmd in Linux and Manage Amazon s3 Buckets
  • How to Install AnyDesk on Ubuntu, Debian and LinuxMint (Alternative of TeamViewer)
  • How to Setup Selenium with ChromeDriver on Ubuntu 16.04
  • How to Install MySQL on macOS Sierra and High Sierra
All rights reserved. © 2013-2018 TecAdmin.net. This site uses cookies. By using this website you agree our term and services