Page tree
Skip to end of metadata
Go to start of metadata

Overview

Apache Tomcat® allows you to serve Java-based applications on your Apache webserver. EasyApache 4 provides the option to install Tomcat 8.5.

For more information about the Apache Tomcat open-source project, visit the Apache Tomcat website.

Important:

  • You can only install Tomcat manually. You cannot migrate from EasyApache 3 to EasyApache 4 if your server runs Tomcat. We will add this functionality in cPanel & WHM version 76.
  • We strongly recommend that only experienced Tomcat administrators install Tomcat.
  • Tomcat is experimental at this time. You must install the The Experimental Repository to use Tomcat.

How to install Tomcat

Requirements

Tomcat requires root-level access to install. 

Install Tomcat

To install Tomcat, run the following command on the command line as the root user:

yum install ea-tomcat85

Uninstall Tomcat

To uninstall Tomcat, run the following command on the command line as the root user: 

yum remove ea-tomcat85

Configuration

Tomcat 8.5 places its configuration files in the following location:

/opt/cpanel/ea-tomcat85/conf

Add Tomcat support for a domain

To add Tomcat 8.5 support to a domain, run the following command as the root user:

/usr/local/cpanel/scripts/ea-tomcat85 [argument] [option]


The /scripts/ea-tomcat85 script accepts the following arguments, where domain represents the domain you wish to change and command represents an argument for the script:

ArgumentDescriptionExample
status domainView the Tomcat 8.5 status of a domain./usr/local/cpanel/scripts/ea-tomcat85 status example.com
add domain

Add Tomcat 8.5 support to a domain, subdomain, parked domain, or addon domain.

Note:

You can also pass the --no-flush option. If you pass the --no-flush option, the script will not rebuild your Apache configuration file or restart Apache and Tomcat 8.5.

/usr/local/cpanel/scripts/ea-tomcat85 add example.com
rem domain

Remove Tomcat 8.5 support from a domain.

Note:

You can also pass the --no-flush option. If you pass the --no-flush option, the script will not rebuild your Apache configuration file or restart Apache and Tomcat 8.5.

/usr/local/cpanel/scripts/ea-tomcat85 rem example.com
listView the domains that support Tomcat 8.5./usr/local/cpanel/scripts/ea-tomcat85 list
flush

Rebuild the Apache configuration file then restart Apache and Tomcat 8.5.

Note:

You only need to use this option if you passed the --no-flush option.

/usr/local/cpanel/scripts/ea-tomcat85 flush
hint [command]

Display the abbreviated help information.

Note:

The command is optional. If you specify a command, only that command's abbreviated help information will display.

/usr/local/cpanel/scripts/ea-tomcat85 hint add
help [command]

Display the script's help information.

Note:

The command is optional. If you specify a command, only that command's help information will display.

/usr/local/cpanel/scripts/ea-tomcat85 help

When you run the /scripts/ea-tomcat85 script with the add or rem arguments, the script will ensure that the proper include files exist. It will also perform the following steps:

  • Rebuild the httpd.conf file.
  • Restart Tomcat.
  • Restart httpd.

Running Tomcat

Note:

Tomcat may take a long time to start to serve requests on initial startup. This usually happens on virtual machines. For suggestions of ways to start your Tomcat server faster, read the Tomcat Faster Startup documentation. System administrators must choose the solution that best fits their needs.

When you add a domain with the /usr/local/cpanel/scripts/ea-tomcat85 script, the script configures the domain for .jsp support.

Custom configurations

The /usr/local/cpanel/scripts/ea-tomcat85 script will create include files and add an entry to the /opt/cpanel/ea-tomcat85/conf/server.xml file. You must configure any custom behavior manually. To change how Tomcat interacts with Apache, edit or create the appropriate file in the /etc/apache2/conf.d/userdata/ directory. For more information, read our Advanced Apache Configuration and Modify Apache Virtual Hosts with Include Files documentation. 

Important:

Do not manually edit the include files or the server.xml file that the Tomcat script creates.

Proxy an app with AJP

Tomcat 8.5 uses AJP to serve applications in EasyApache 4. 

To serve an app via AJP, you must configure AJP in your virtual host's include files. Your entry might resemble the following example, where /docs represents the app you wish to use: 

ProxyPass "/docs" "ajp://127.0.0.1:8009/docs"

Differences between Tomcat in EasyApache 3 and EasyApache 4

EasyApache 3 handles Tomcat differently than EasyApache 4. EasyApache 4 provides Tomcat 8.5, rather than Tomcat 7. 

EasyApache 4 uses the mod_proxy_ajp Apache module rather than the mod_jk connector. Due to security concerns, EasyApache 4 does not configure WAR file deployment the way that EasyApache 3 did. You can still use WAR files, but you must configure them manually

Additional documentation