Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Web Servers»Tomcat»How to Install Tomcat 9 on Debian 11/10/9

    How to Install Tomcat 9 on Debian 11/10/9

    By RahulFebruary 18, 20224 Mins Read

    Apache Tomcat 9 is the latest version available for installation. Apache Tomcat is a product of 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.

    Advertisement

    The current Apache Tomcat 9.0.50 release is available. This tutorial will guide you through step by step installation of the Apache Tomcat server on Debian. Let’s follow to Install Apache Tomcat 9 on Debian 10/9/8.

    Step 1 – Prerequisites

    You must have root user or sudo privileged user access to install Tomcat on the Debian system. Login to your Debian system with shell access. Use SSH to get access to the remote Linux system.

    ssh [email protected] 
    

    Now update the apt package manager cache and upgrade the current packages of the system.

    sudo apt update
    sudo apt upgrade
    

    Step 2 – Install Java

    You must have Java installed on the system before installing Apache Tomcat on a Linux VPS. Tomcat 9 required Java 8 or later versions to work.

    java -version
    
    java version "1.8.0_161"
    Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
    Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)
    

    If you don’t have Java installed on your system or installed a lower version, Use this tutorial to install Java 8 on a Debian machine.

    Step 3 – Install Apache Tomcat 9 on Debian

    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.

    wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.58/bin/apache-tomcat-9.0.58.tar.gz
    tar xzf pache-tomcat-9.0.58.tar.gz
    mv apache-tomcat-9.0.58 /usr/local/tomcat9
    

    Step 4 – Configure Tomcat on Debian

    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. Set all these variables in a file /etc/profile.d/tomcat9.sh.

    echo 'export CATALINA_HOME="/usr/local/tomcat9"' > /etc/profile.d/tomcat9.sh
    echo 'export JAVA_HOME="/usr/lib/jvm/java-8-oracle"' >> /etc/profile.d/tomcat9.sh
    echo 'export JRE_HOME="/usr/lib/jvm/java-8-oracle/jre"' >> /etc/profile.d/tomcat9.sh
    

    This file will automatically load variables after system reboot. To load in current environment run command:

    source /etc/profile.d/tomcat9.sh
    

    Step 5 – Setup Tomcat User Accounts

    Y 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 6 – 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 the application-specific context.xml file.

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

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

    Tomcat enable remote access

    Step 7 – Start 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.

    chmod +x ./bin/startup.sh
    ./bin/startup.sh
    

    [Sample Output]

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

    Use below command to stop tomcat server on your system.

    ./bin/shutdown.sh
    

    Step 8 – Access Tomcat in Browser

    Tomcat service uses default port 8080. Open your favorite web browser and connect to your server on port 8080. This will provide access to the Tomcat setup on your system.

    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 

    Tomcat 9 on Debian

    Apache Apache Tomcat 9 install tomcat on debian tomcat Tomcat 9
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    Comparing Apache MPM Worker and Prefork: Which is Right for Your Application

    How to Install Apache (httpd) on RHEL & CentOS Stream 9

    How to Install LAMP Stack on RHEL & CentOS Stream 9

    View 5 Comments

    5 Comments

    1. Francisco on April 22, 2021 8:38 pm

      Thanks it’s help me a lot.

      Reply
    2. Bruno on September 27, 2019 1:57 pm

      this code is wrong:
      echo ‘export CATALINA_HOME=”/usr/local/tomcat9″‘ > /etc/profile.d/tomcat9.sh

      change to:
      echo ‘export CATALINA_HOME=”/usr/local/tomcat9″‘ > /etc/profile.d/tomcat9.sh
      apache-tomcat9

      Reply
      • Bruno on September 27, 2019 1:58 pm

        this code is wrong:
        echo ‘export CATALINA_HOME=”/usr/local/tomcat9″‘ > /etc/profile.d/tomcat9.sh

        change to:
        echo ‘export CATALINA_HOME=”/usr/local/apache-tomcat9″‘ > /etc/profile.d/tomcat9.sh

        Reply
        • Rahul on September 30, 2019 8:02 am

          Thanks Bruno.

          Reply
    3. Geoffrey HOLEC on July 26, 2019 9:47 am

      Hello,

      I think the service is not prépared to restart on reboot…

      KR

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • How to List Manually Installed Packages in Ubuntu & Debian
    • 10 Bash Tricks Every Developer Should Know
    • How to Validate Email Address in JavaScript
    • Firewalld: Common Firewall Rules and Commands
    • 12 Apk Commands in Alpine Linux Package Management
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.