How to Set Up a Web Server with Tomcat
Apache Tomcat is a popular open-source web server and servlet container for running Java applications. This guide will walk you through installing and configuring Tomcat on a Linux server.
What Is The Tomcat
- A Linux server (Ubuntu recommended)
- Sudo or root access
- Basic knowledge of the terminal
Step 1: Update Your Server
Start by updating the package list:
sudo apt update
sudo apt upgrade
Step 2: Install Java
Tomcat requires Java to run. Install the default Java Development Kit (JDK):
sudo apt install default-jdk
Verify the installation:
java -version
Step 3: Download Tomcat
Visit the Apache Tomcat website and download the latest version:
wget https://downloads.apache.org/tomcat/tomcat-9/v9.0.56/bin/apache-tomcat-9.0.56.tar.gz
Extract the archive:
tar xzvf apache-tomcat-9.0.56.tar.gz
Step 4: Move and Set Permissions
Move Tomcat to the /opt
directory and set permissions:
sudo mv apache-tomcat-9.0.56 /opt/tomcat
sudo chown -R $USER:$USER /opt/tomcat
Step 5: Start Tomcat
Navigate to the bin
directory and start Tomcat:
cd /opt/tomcat/bin
./startup.sh
Tomcat should now be running on port 8080.
Step 6: Access Tomcat Web Interface
Open a web browser and navigate to:
http://<your-server-ip>:8080
You should see the Tomcat welcome page.
Conclusion
You have successfully installed and configured Apache Tomcat on your Linux server. Tomcat is now ready to host your Java web applications.