FreeKB - Tomcat Install Tomcat on Linux
Tomcat - Install Tomcat on Linux

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

cd /tmp
wget http://www.trieuvan.com/apache/tomcat/tomcat-<version>/<version>/bin/apache-tomcat-<version>.tar.gz

 

Extract the gzip compressed tar archive. In this example, it is extracted to the /opt directory.

tar -zxvf apache-tomcat-<version>.tar.gz --directory /opt

 

By default, Tomcat will listen on the following ports:

  • Port 8005 for SHUTDOWN connections
  • Port 8080 for HTTP connections
  • Port 8443 for HTTPS connections

Use the netstat command to determine if any other services are using ports 8005, 8080 and 8443.

netstat -ano | grep 8005
netstat -ano | grep 8080
netstat -ano | grep 8443

 

If there is a service using port 8005, 8080 or 8443, update Tomcat to use some other unused port.

Optionally, rename the extracted directory from "apache-tomcat-<version>" to "tomcat".

mv /opt/apache-tomcat-<version> /opt/tomcat

 

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

yum install jre

 

If you have a firewall, such as iptable or firewalld (Linux), open ports 8080 and 8443.

You can now start Tomcat. The ps command can be used to verify that Tomcat is running. If the ps command returns something like this, Tomcat is running.

ps -ef | grep -i tomcat<version> | grep -v grep

root  86359      1  2 08:48 pts/0    00:00:02 /usr/bin/java -Djava.util.logging.config.file=/opt/Apache/Tomcat9.0.37/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dignore.endorsed.dirs= -classpath /opt/Apache/Tomcat9.0.37/bin/bootstrap.jar:/opt/Apache/Tomcat9.0.37/bin/tomcat-juli.jar -Dcatalina.base=/opt/Apache/Tomcat9.0.37 -Dcatalina.home=/opt/Apache/Tomcat9.0.37 -Djava.io.tmpdir=/opt/Apache/Tomcat9.0.37/temp org.apache.catalina.startup.Bootstrap start

 

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.

<welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

 

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.

 


LOG FILES

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 6f255 in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |