How to install Tomcat in Linux

Home > Search > How-to

Download Tomcat from If you are using a text-only version of Linux, use wget to download the gzip compressed tar archive.

~]# cd /tmp
~]# wget<version>/<version>/bin/apache-tomcat-<version>.tar.gz


Extract the gzip compressed tar archive.

~]# tar -zxvf /tmp/apache-tomcat-9.0.0.M21.tar.gz -C /opt


Rename the extracted directory from "apache-tomcat-9.0.0.M26" to "tomcat".

~]# mv /etc/apache-tomcat-<version> /opt/tomcat


If Java Runtime Environment (JRE) is not installed, use apt-get or yum to install JRE.

~]# yum install jre


Run the startup script.

~]# /opt/tomcat/bin/
. . .
Tomcat started.


The ps command can be used to verify that Tomcat is running. If the ps command displays two or more processes, where one of the process is Java, this means Tomcat is running.

~]# ps -ef | grep tomcat
root  13044 12965  0  17:37  pts/0  00:00:00  grep --color=auto  tomcat
root  18695     1  0  Sep08  ?      00:03:00  /usr/bin/java . . .


On a PC in the same subnet as the web server, navigate to http://localhost:8080. The default page should be displayed.


The /opt/tomcat/conf/web.xml file will contain the default documents. In this example, the default documents are index.html, index.htm, and index.jsp. By default, only the index.jsp file will be installed, at /opt/tomcat/webapps/ROOT/index.jsp.



Directories can be added to the /opt/tomcat/webapps directory, and then files can be added to the new directory. For example, a directory named testing can be created.

~]# mkdir /opt/tomcat/webapps/testing


Files can then be added to the /opt/tomcat/webapps/testing directory. For example, adding example.jsp with the text Hello there will allow you to navigate to http://localhost:8080/testing/example.jsp and display the Hello there page.



If some problem occurs, check the /opt/tomcat/logs/catalina.out file.

Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter in the box below so that we can be sure you are a human.