Apache Tomcat (sometimes referred to as simply Tomcat) is a popular open-source web server software used to set up Java-based server environments. The technologies used in Tomcat include Java Servlet, Java Server Pages, Java Expression Language, and WebSocket and provides an HTTP server environment ideal for running Java-based applications. Apache Tomcat can be installed on most popular operating systems such as Ubuntu and CentOS. In this article, we will outline how to install Apache Tomcat 8 on your Ubuntu server. Please note, in order to complete the steps in this guide you will need to ensure you have root SSH access.
Topics Include:
- Installing Apache Tomcat
- Testing Apache Tomcat
Install Apache Tomcat 8 on your Dedicated Hosting server and start running your Java applications today!
Installing Apache Tomcat
- First, you will need to make (mkdir) a Tomcat folder and change directory (cd) into it using the following commands:
mkdir /opt/tomcat
cd /opt/tomcat
- Next, you will download the Apache Tomcat archive file and then extract the archive using the following commands:
wget tomcat.tar.gz
tar -xvzf tomcat.tar.gz
- Then, ensure that Java is installed with the following command:
java -version
If Java is not installed, you must first install it before proceeding.
- Then, you will need to configure your .bashrc file and set the environment variables. To do this, you will use the nano text editor to modify the .bashrc file using the following command:
nano ~/.bashrc
- Add the following lines to the bottom of the .bashrc file:
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
export CATALINA_HOME=/opt/tomcat/apache-tomcat-8.5.32
- Press Ctrl + X to save the file and exit the nano text editor.
- Register the changes to the .bashrc file with the following command:
~/.bashrc
Testing Apache Tomcat
- Before testing to see if Tomcat was set up successfully, run the startup script with the following command:
$CATALINA_HOME/bin/startup.sh
- If the installation was successful, you can visit your server IP followed by :8080 and you should see a Tomcat splash page.
Congratulations, you have successfully installed Apache Tomcat!