Install Apache Tomcat on Ubuntu

Ubuntu repository does not provide the latest version of Apache Tomcat. If you are desired to install the latest version of Apache Tomcat and to add it to the Eclipse, this article is for you.


Step 1:
Download the latest version of Apache Tomcat from this link.

Step 2:
Open the Terminal (Ctrl + Alt + T) and enter the following command to change the directory.
cd /opt/

Step 3:
Enter the command given below to extract the Tomcat from  the ~/Downloads directory. If your downloaded file is in any other directory, replace the last parameter by the actual file path.
sudo tar -xvzf ~/Downloads/apache-tomcat-8.0.26.tar.gz

Step 4: (Optional)
Rename the folder name to apache-tomcat.
sudo mv apache-tomcat-8.0.26/ apache-tomcat/

Step 5:
Tomcat creates some files at the runtime inside this folder (Log files and some other configuration files). If you want to start Tomcat without root privilege, it is required to change the permission of this directory. Enter the following command to change the permission of apache-tomcat folder.
sudo chmod -R 777 apache-tomcat/

Step 6:
An environment variable has to be added to the system. Enter the following command in the terminal to open the /etc/environment in gedit.
sudo gedit /etc/environment

Step 7:
Add the following line at the end of the file. Save and close the gedit.
CATALINA_HOME="/opt/apache-tomcat"

The /etc/environment before the modification.


The /etc/environment after the modification.


Step 8:
Reload the environment variables to the current terminal using this command.
source /etc/environment

Step 9:
Enter the following command to start the Tomcat server.
$CATALINA_HOME/bin/startup.sh

Step 10:
Visit to the following URL.
http://localhost:8080/

If you get the Apache Tomcat home page, you have successfully installed the Apache Tomcat in your system.

Step 11:
To stop the Tomcat, enter the following command.
$CATALINA_HOME/bin/shutdown.sh

Integrate Tomcat with Eclipse
If you do not have the Eclipse, follow this link and install the Eclipse first.

Step 1:
Open the Eclipse.

Step 2:
Goto Windows → Preferences in the menu bar and select the Runtime Environments under the Server.


Step 3:
Click on the 'Add' button.

Step 4:
Select your Apache Tomcat version under the 'Apache' root and click 'Next'.


Step 5:
Browse and select the Tomcat installation directory.


Step 6:
Click on the 'Finish' button

Step 7:
Click on the 'OK' button to close the Preferences dialog.


Now you are ready to use Apache Tomcat from Eclipse.
Previous
Next Post »

8 comments

Write comments
Steven Spielberg P
AUTHOR
June 15, 2016 at 6:10 AM delete

Thanks

Reply
avatar
Gobinath
AUTHOR
June 15, 2016 at 6:30 AM delete

You are welcome Steven

Reply
avatar
George Udosen
AUTHOR
July 6, 2016 at 4:39 PM delete

Hi Gobinath, Thanks for the tutorial. If I ask what happens to my apache install running on port 8080 when I install tomcat on the same port?

Reply
avatar
Gobinath
AUTHOR
July 7, 2016 at 9:33 AM delete

Hi,
Two processes cannot listen to the same port. I usually allocate port 80 for Apache and port 8080 for Tomcat. Depending on your preference change the port of either of them.

Reply
avatar
Android272
AUTHOR
August 18, 2016 at 9:48 AM delete

I am getting "Unknown version of Tomcat was specified." when I go to select the Tomcat installation directory.

Reply
avatar
Gobinath
AUTHOR
August 18, 2016 at 11:29 AM delete

Hi,
I hope you have installed the Tomcat as given in this tutorial. Make sure that you are providing the parent folder of Tomcat and your Eclipse supports the specific Tomcat version.

Reply
avatar
Android272
AUTHOR
August 19, 2016 at 6:17 PM delete

I am using Tomcat 8.5.4, Spring Tool Suite Version: 3.8.0.RELEASE, Java 8, and Ubuntu 16.04. I am not sure how to check if I am using the right tomcat version.

Reply
avatar
Aayush Shah
AUTHOR
July 24, 2017 at 11:36 PM delete

Thank you so much!!
It helped me for installing tomcat v8.5 on ubuntu 16.04 for eclipse neon.
Searched alot of sites,none of them were useful.Thank you for the beautiful post.

Reply
avatar

Contact Form

Name

Email *

Message *