Apache Tomcat Installation Guide: Step-by-Step InstructionsApache Tomcat is a popular open-source web server and servlet container that enables the execution of Java applications. It’s often used for developing and deploying Java-based web applications. This guide provides a comprehensive, step-by-step approach to installing Apache Tomcat on your local machine.
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
-
Visit the Official Tomcat Website:
Go to the Apache Tomcat official download page. -
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. -
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:
-
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
).
-
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.
-
Set the Path Variable:
- Find the
Path
variable in the “System variables” section and click “Edit.” - Add
%CATALINA_HOME%in
to the list.
- Find the
For Linux:
- 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
- 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:
- Execute Startup Script:
Open a Command Prompt and run the following command:
cd %CATALINA_HOME%in startup.bat
- Access Tomcat:
Open a web browser and navigate tohttp://localhost:8080
. You should see the Tomcat welcome page.
For Linux:
- Make the Startup Script Executable:
Run the following command:
sudo chmod +x /opt/tomcat/bin/*.sh
- Execute Startup Script:
In the terminal, run:
$CATALINA_HOME/bin/startup.sh
- Access Tomcat:
Open a web browser and go tohttp://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:
-
Change the Default Port:
- Locate the
server.xml
file in theconf
directory. - Change the
port
attribute of the<Connector>
tag from8080
to your desired port.
- Locate the
-
Set Up Users for Manager App:
To access the Tomcat Manager app, add users intomcat-users.xml
located in theconf
directory. Add the following code inside the<tomcat-users>
tag:
<role rolename="manager-gui"/> <user username="admin" password="admin" roles="manager-gui"/>
Leave a Reply