Getting Started with Apache Tomcat: A Comprehensive Beginner’s Guide


Prerequisites

Before you begin the installation process, ensure you have the following prerequisites:

  • Java Development Kit (JDK): Apache Tomcat requires a JDK to run. You can download the latest version from the official Oracle website or AdoptOpenJDK.

  • Operating System: This guide covers installations on Windows and Linux. Adjustments may be needed based on your environment.


Step 1: Download Apache Tomcat

  1. Visit the Official Tomcat Website:
    Go to the Apache Tomcat official download page.

  2. Select the Version:
    Choose the latest stable version. As of October 2025, this could be Tomcat 10 or later. Ensure you select the Binary Distribution.

  3. Choose Your Distribution:
    You typically have two options:

    • .zip file for Windows
    • .tar.gz file for Linux

Click on the appropriate link to download.


Step 2: Install Apache Tomcat

For Windows:
  1. Extract the Downloaded File:

    • Right-click on the .zip file and select “Extract All.”
    • Choose a destination folder (e.g., C:pache-tomcat-10.0.x).
  2. Set Environment Variables:

    • Navigate to Control Panel > System and Security > System > Advanced System Settings.
    • Click on “Environment Variables.”
    • Under “System variables,” add a new variable named CATALINA_HOME and set its value to the Tomcat installation directory.
  3. Set the Path Variable:

    • Find the Path variable in the “System variables” section and click “Edit.”
    • Add %CATALINA_HOME%in to the list.
For Linux:
  1. Extract the Downloaded File:
    Open a terminal and navigate to the directory where you’ve downloaded the tar.gz file. Then run:
   tar -xvzf apache-tomcat-10.0.x.tar.gz 

Move the extracted folder to a preferred location, for instance:

   sudo mv apache-tomcat-10.0.x /opt/tomcat 
  1. Set Environment Variables:
    Open your .bashrc or .bash_profile in a text editor and add the following lines:
   export CATALINA_HOME=/opt/tomcat    export PATH=$PATH:$CATALINA_HOME/bin 

Save the file and run:

   source ~/.bashrc 

Step 3: Start Apache Tomcat

For Windows:
  1. Execute Startup Script:
    Open a Command Prompt and run the following command:
   cd %CATALINA_HOME%in    startup.bat 
  1. Access Tomcat:
    Open a web browser and navigate to http://localhost:8080. You should see the Tomcat welcome page.
For Linux:
  1. Make the Startup Script Executable:
    Run the following command:
   sudo chmod +x /opt/tomcat/bin/*.sh 
  1. Execute Startup Script:
    In the terminal, run:
   $CATALINA_HOME/bin/startup.sh 
  1. Access Tomcat:
    Open a web browser and go to http://localhost:8080. You should see the Tomcat welcome page.

Step 4: Configure Tomcat (Optional)

To enhance the functionality of Apache Tomcat, you may want to configure some settings:

  1. Change the Default Port:

    • Locate the server.xml file in the conf directory.
    • Change the port attribute of the <Connector> tag from 8080 to your desired port.
  2. Set Up Users for Manager App:
    To access the Tomcat Manager app, add users in tomcat-users.xml located in the conf directory. Add the following code inside the <tomcat-users> tag:

   <role rolename="manager-gui"/>    <user username="admin" password="admin" roles="manager-gui"/> 

Step 5: Stopping Apache Tom

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *