How to Install Apache Tomcat on Windows
Introduction
Apache Tomcat is a popular open-source web server and servlet container that allows you to run Java applications. Installing Apache Tomcat on a Windows machine is a straightforward process. This guide will walk you through the steps to successfully install and configure Apache Tomcat on Windows.
Prerequisites
Before installing Tomcat, ensure that you have the following prerequisites:
- Java Development Kit (JDK)
Apache Tomcat requires Java to run. If you don’t have the JDK installed, follow this guide. - Administrative Privileges
Ensure you have administrative rights on the Windows machine to install software and configure services.
Step 1: Download Apache Tomcat
- Visit the Apache Tomcat Download Page.
- Look for the Binary Distributions section and download the
32-bit/64-bit Windows Service Installer
or thezip file
if you prefer a manual installation.
Step 2: Install and Configure Apache Tomcat
Option 1: Using Windows Service Installer
- Run the Installer
Double-click the downloaded.exe
file. - Follow Installation Instructions
- Accept the license agreement.
- Choose the installation directory (default is usually fine).
- Enter the Tomcat Administrator and Manager passwords (for the Manager App).
- Choose whether to run Tomcat as a service (recommended for production use).
- Complete the Installation
Once finished, the installer will set up Tomcat as a Windows service.
Option 2: Manual Installation Using Zip File
- Extract the Zip File
- Right-click on the downloaded
.zip
file and select Extract All. - Choose a destination folder (e.g.,
C:\
,C:\Users\<username>
).
- Right-click on the downloaded
- Set CATALINA_HOME Environment Variable
- Right-click on
This PC
orComputer
on your desktop and selectProperties
. If there is no shortcut on the desktop, open File Explorer, navigate to This PC in the left sidebar, right-click on it, and select Properties. - Click on
Advanced system settings
and thenEnvironment Variables
. - Click
New
underSystem variables
and setCATALINA_HOME
as the variable name. - Set the variable value to the path where you extracted Tomcat (e.g.,
C:\apache-tomcat-<version>
). - Click
OK
to save.
- Right-click on
- Update the PATH Variable
- Add the
bin
directory of Tomcat to thePath
variable (e.g.,C:\apache-tomcat-<version>\bin
).
- Add the
- Configure Tomcat as a Windows Service (Optional)
- Open Command Prompt as an administrator. Right-click on the Command Prompt icon and select
Run as administrator
. - Navigate to the Tomcat
bin
directory:1
cd %CATALINA_HOME%\bin
- Run the
service.bat
script to install Tomcat as a service:1
service.bat install
- Open Command Prompt as an administrator. Right-click on the Command Prompt icon and select
- Configure Administration Tools (Optional)
- Open the
tomcat-users.xml
file located in theconf
directory:1
C:\apache-tomcat-<version>\conf\tomcat-users.xml
- Add the following configuration inside the
<tomcat-users>
tags:1 2 3 4
<tomcat-users> <role rolename="manager-gui"/> <user username="admin" password="admin" roles="manager-gui"/> </tomcat-users>
- Save the changes.
- After starting Tomcat, you will be able to access the Manager App and Host Manager by navigating
to the following URLs:
1 2
http://localhost:8080/manager http://localhost:8080/host-manager
- Open the
Step 3: Start Apache Tomcat
After installing Tomcat, you have two options to start it: either run it directly as an application or as a Windows service.
Option 1: Running Tomcat Directly as an Application
If you prefer to run Tomcat as a standalone application without using Windows services, you can manually start it via the command line:
- Open
Command Prompt
as an administrator (search forcmd
, right-click, and selectRun as administrator
). - Navigate to the
bin
directory of your Tomcat installation:1
cd C:\apache-tomcat-version\bin
- Start Tomcat by executing the following command:
1
catalina.bat start
You can also stop it with:
1
catalina.bat stop
Option 2: Running Tomcat as a Windows Service
If you installed Tomcat using the Windows Service Installer
, Tomcat is set up as a Windows service,
which allows you to start and stop it through the system’s service manager.
- Press
Win + R
, typeservices.msc
, and pressEnter
. - In the
Services
window, scroll down to findApache Tomcat
(e.g., Tomcat10). - Right-click on
Apache Tomcat
and selectStart
to launch the service.
Additionally, you can start or stop the service using the command line (run as administrator) with the following commands:
- To start the service:
1
net start Tomcat9
- To stop the service:
1
net stop Tomcat9
Step 4: Access Tomcat in the Browser
Once Tomcat is running, you can access the Tomcat web page in your browser at the following URL:
1
http://localhost:8080
You should see the Tomcat welcome page, which indicates that Tomcat is successfully installed and running.
If you have completed the configuration for the Manager App and Host Manager, you will also have access to the following URLs:
1
2
http://localhost:8080/manager
http://localhost:8080/host-manager
Conclusion
You have successfully installed Apache Tomcat on your Windows machine. By following these steps, you’ve set up the necessary Java environment, downloaded and configured Tomcat, and even set it up to run as a Windows service. Tomcat is now ready to host your Java web applications reliably. For advanced configurations, refer to the official Tomcat documentation.