Apache Tomcat in RHEL 7

Here are some notes for using the built-in Apache Tomcat package in Red Hat Enterprise Linux (RHEL) 7. For an overview of installing and turning on Tomcat, see my previous post RHEL 7 Administration Notes. In brief, use yum to install the tomcat package and systemctl to control the tomcat service. The previous post also gives a short example for using the mod_proxy_ajp for optimized reverse proxy behind the Apache HTTPD Web Server (provides front-end performance, load balancing support, and easier SSL configuration). Optionally use firewall-cmd if you want end-users to connect directly to Tomcat.

One of the most important Distribution-Specific things to know for a package like Tomcat is the default location of user configurable folders and files. Here are some key file and folder locations for the Tomcat package distributed with RHEL 7.

  • /var/lib/tomcat/webapps # deploy your web apps here
  • /etc/tomcat/* # Tomcat server configuration files here (server.xml, etc)
  • /var/log/tomcat/* # Tomcat log files are stored here and auto-rotated by RHEL 7
  • /etc/tomcat/tomcat.conf # JAVA_OPTS like -D* and -X* are set here for RHEL 7
  • For Tomcat RAM adjustment
    • add CATALINA_OPTS with -Xmx in /etc/tomcat/tomcat.conf
    • see default -Xmx with command: java -XshowSettings # listed as Max. Heap Size

If you want to use the Tomcat Manager (Admin Web App), you can install that as a separate package.

  • yum install tomcat-admin-webapps
  • Edit /etc/tomcat/tomcat-users.xml
    • Un-comment admin/manager roles and add a new user with both roles.
  • systemctl restart tomcat # Restart service to activate manager web app
  • Connect to your Tomcat with a server-relative URL of /manager/ to use the Admin Web App. Examples: https://SRV.DOM.COM:8443/manager/ -or- http://SRV.DOM.COM:8080/manager/

Good luck with your RHEL 7 Tomcat projects! Hopefully using the provided packages will help make your web app deployment easier and add some extra security by providing Tomcat patches direct from Red Hat.

Advertisements

About notesbytom

Keeping technology notes on WordPress.com to free up my mind to solve new problems rather than figuring out the same ones repeatedly :-).
This entry was posted in Linux and tagged , . Bookmark the permalink.

3 Responses to Apache Tomcat in RHEL 7

  1. Pingback: Tomcat Multiple Instances RHEL 7 CentOS 7 | Notes by Tom

  2. hema says:

    Hi
    Do I need to set http service to use tomcat7 that I installed on rhel7 server.?

    • notesbytom says:

      Hello @hema, you can optionally use Apache httpd as a reverse proxy for Tomcat (AJP or HTTP ProxyPass and ProxyPassReverse). This is sometimes referred to as a “load balancer” if you have one httpd directing web-app traffic to multiple tomcat instances. You can also have clients connect directly to Tomcat if desired – skipping any httpd and using the servlet container directly for client requests.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s