We're here to assist with any of your needs, don't hestitate to reach out.
Apache Tomcat is an open-source web server and servlet container used to deploy Java-based web applications. It provides a lightweight and efficient environment for running Java servlets and JavaServer Pages (JSPs).
To begin, we need to update the system packages to their latest version. Open a terminal and run the following commands:
Tomcat requires Java to be installed on your system. Install the default JDK package by running the following command:
Go to the official Apache Tomcat website and navigate to the Tomcat 9 Downloads page. Copy the URL of the latest version of Tomcat 9 (e.g., https://downloads.apache.org/tomcat/tomcat-9/v9.0.46/bin/apache-tomcat-9.0.46.tar.gz).
Back in the terminal, change to the /tmp directory and download the Tomcat package using wget:
Once the download is complete, extract the Tomcat archive using the following command:
Create a symbolic link to have a shorter path to the Tomcat installation directory:
Change ownership and permissions of the Tomcat installation directory:
Edit the ~/.bashrc file to set the required environment variables:
To start the Tomcat service, run the following command:
If you have a firewall enabled on your system, you need to allow inbound traffic on port 8080. Run the following command to open the Tomcat port:
sudo apt update
sudo apt upgrade
sudo apt install default-jdk
cd /tmp
wget [paste_the_url_copied_above]
sudo tar -xf apache-tomcat-*.tar.gz -C /opt
sudo ln -s /opt/apache-tomcat-* /opt/tomcat
sudo chown -R $USER:$USER /opt/tomcat
sudo chmod +x /opt/tomcat/bin/*.sh
nano ~/.bashrc
Add the following lines at the end of the file:
export CATALINA_HOME="/opt/tomcat"
export JAVA_HOME="/usr/lib/jvm/default-java"
Save and close the file, then apply the changes using:
source ~/.bashrc
$CATALINA_HOME/bin/startup.sh
To verify that Tomcat is running, open a web browser and visit:
http://localhost:8080
sudo ufw allow 8080
Now, your Apache Tomcat installation should be complete and ready to use.
For more advanced configuration and securing Apache Tomcat, refer to the official documentation: https://tomcat.apache.org/
What our customers say about us
Create your free account today.