How to install Apache Tomcat on Linux Cloud Servers

2020-04-15 By Aaron 8028 Views linux tomcat development
10 reviews

Apache Tomcat is an open-source implementation of the Java Servlet, JavaServer Pages, Java Expression Language and WebSocket technologies.


See the instructions for installing Apache Tomcat on CentOS, Ubuntu & Debian below.


Prerequisites

  • Open port 8080 in the firewall if installed.


Installation in CentOS 7/8


  1. Install tomcat on your server by using the below command.

    # yum install tomcat
    

    tomcat11

  2. There are several additional packages that many users, particularly those who are new to Tomcat, will find useful. Install them with the following command and this will install the Tomcat root webpage (tomcat-webapps), the web admin manager (tomcat-admin-webapps) and the official Tomcat documentation files (tomcat-docs-webapp and tomcat-javadoc).

    # yum install tomcat-webapps tomcat-admin-webapps tomcat-docs-webapp tomcat-javadoc
    

    tomcat2

  3. If you are running the Apache, please stop and start the tomcat. You can use the below commands.

    # systemctl stop httpd
    
    # systemctl start tomcat
    

    tomcat3

    tomcat4

    You can verify that Tomcat is running by visiting the URL http://example.com/IPaddress:8080

    You will get the below page.

    tomcat5


Installation in Ubuntu / Debian


  1. The first thing you will want to do is update your apt-get package lists.

    # apt-get update
    

    tomcat6

  2. Run the below command to install Tomcat9 on your ubuntu server.

    # apt-get install tomcat9
    

    tomcat7

  3. Edit the below file /etc/default/tomcat9 to change Java options that Tomcat uses when it starts.

    # vi /etc/default/tomcat9
    
  4. Find the JAVA_OPTS line and replace it with the following.

    # JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom -Djava.awt.headless=true -Xmx512m –XX:MaxPermSize=256m -XX:+UseConcMarkSweepGC"
    

    tomcat8

  5. Save and exit.

  6. Restart Tomcat with this command:

    # service tomcat9 restart
    

    tomcat9

  7. Now you can access the default splash page by going to your domain or IP address followed by :8080 in a web browser.

    You will get the page like below.

    tomcat10

Related Tutorials

What do you think about this article?

Rate this article
LayerStack Promotion
Need assistance?

Try this guide to receive free bundled services at signup on a new free account.

Sign Up

Your Feedback Is Important

We hope you’ll give the new products and updates a try. If you have an idea for improving our products or want to vote on other user ideas so they get prioritized, please submit your feedback on our Community platform. And if you have any questions, please feel free to ask in the Community or contact our Technical Support team.