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 that is used to serve Java-based web applications. It provides an environment to run Java code and serve dynamic content over the web.
Before installing Apache Tomcat, it is recommended to update the package manager to ensure that you have the latest software versions. Open a terminal and execute the following command:
sudo apt update
Tomcat requires Java Development Kit (JDK) to run. You can install OpenJDK, which is an open-source implementation of the Java SE platform. Execute the following command in the terminal:
sudo apt install default-jdk
Visit the official Apache Tomcat website (https://tomcat.apache.org) and download the latest stable version of Tomcat. Alternatively, you can use the following command to download it directly from the terminal:
wget https://downloads.apache.org/tomcat/tomcat8/v8.5.63/bin/apache-tomcat-8.5.63.tar.gz
Extract the downloaded file using the following command:
tar -xf apache-tomcat-8.5.63.tar.gz
Move the extracted Tomcat directory to a desired location. For example, you can move it to the /opt directory:
sudo mv apache-tomcat-8.5.63 /opt/tomcat
To access Tomcat globally, you need to set up environment variables. Open the .bashrc
file in your preferred text editor:
nano ~/.bashrc
Add the following lines at the end of the file:
export CATALINA_HOME="/opt/tomcat" export PATH="$PATH:$CATALINA_HOME/bin"
Save the file and exit the text editor. To apply these changes, execute the following command or restart the terminal:
source ~/.bashrc
You can now start the Tomcat server by executing the following command:
startup.sh
To verify if Tomcat is running, open a web browser and enter the following URL:
http://localhost:8080
If the Tomcat server is running correctly, you should see the default Tomcat homepage.
To stop the Tomcat server, open a terminal and execute the following command:
shutdown.sh
That's it! You have successfully installed Apache Tomcat on Ubuntu 18.04.
What our customers say about us
Create your free account today.