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

Overview

Note:

This document only applies to Tomcat in cPanel & WHM version 76 and later.


Apache Tomcat® allows you to serve Java-based applications. 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:

  • 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.
  • Tomcat can present security issues on systems with multiple users. We strongly recommend that you understand the risks of this feature before you use it. For more information, read Tomcat's Security Considerations documentation.

How to install Tomcat

Requirements

Tomcat requires root-level access to install. 

Install Tomcat

In the interface

To install Tomcat, use WHM's EasyApache 4 interface (WHM >> Home >> Software >> EasyApache 4). Tomcat appears in the Additional Packages section.

Remember:

Tomcat only appears if you installed The Experimental Repository.


On the command line

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

yum install ea-tomcat85

Uninstall Tomcat

In the interface

To uninstall Tomcat, use WHM's  EasyApache 4 interface (WHM >> Home >> Software >> EasyApache 4). Tomcat appears in the Additional Packages section.

On the command line

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

yum remove ea-tomcat85

Configuration

In EasyApache 4, Tomcat runs as a per-user private instance. This increases security and allows the user to manage their own Tomcat services, but increases memory load on the server. We strongly recommend that you consider your server's configuration carefully before you enable Tomcat for many users. For more information, read our Tomcat Private Instances documentation.

Tomcat 8.5 places its configuration files in the following location, where user represents the name of the user for which you installed Tomcat:

/home/user/ea-tomcat85/conf

Default configuration

EasyApache 4 makes the following configuration changes from the default Tomcat 8.5 behavior to the  ~/ea-tomcat85/conf/server.xml file:

  • Disable the shutdown port by default.
  • Set the xpoweredBy attribute of all Connectors to a false value.
  • Add the ErrorReportValue class to all Hosts with the  showServerInfo value set to a false value.
  • Set the following Host attributes to a false value:
    • autoDeploy
    • deployOnStartup
    • deployXML

Note:

You may need to make additional security changes, depending on your system's Tomcat requirements. For more information, read Tomcat's Security Considerations documentation.

Add Tomcat support for a user

In the interface

To add Tomcat 8.5 support to a user, use the  Tomcat Manager interface (WHM >> Home >> Software >> Tomcat Manager). 

On the command line

To add Tomcat 8.5 support to a user, 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 user represents the user you wish to change and command represents an argument for the script:

ArgumentDescriptionExample
add user

Add Tomcat 8.5 support to a user.

/usr/local/cpanel/scripts/ea-tomcat85 add user123
rem user

Remove Tomcat 8.5 support from a user.

/usr/local/cpanel/scripts/ea-tomcat85 rem user123
listView the users with a Tomcat 8.5 instance./usr/local/cpanel/scripts/ea-tomcat85 list
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

Jailshell user considerations

Jailshell users cannot see the status of their previously started Tomcat service. The default jailshell permissions only allow users to view their current session's processes. If they attempt to restart an already active service with ubic, the system will launch a duplicate process.

You can address this behavior with one of the following actions:

  • The system administrator can select Always mount a full /proc under the Jailed /proc mount method option of the System section of WHM's Tweak Settings interface (WHM >> Home >> Server Configuration >> Tweak Settings). If you enable this functionality, a jailshelled user can see all running processes. This can allow the jailshell user to break out of their shell.
  • The system administrator can assign the user a normal shell.
  • The system administrator can do nothing. We do not recommend this action, as it may cause confusion and the user may start duplicate processes.

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.

Custom configurations

When you add a user with either the Tomcat Manager interface (WHM >> Home >> Software >> Tomcat Manager) or the /usr/local/cpanel/scripts/ea-tomcat85 script, the script creates an environment that the user can configure for their unique requirements. 

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. 

Proxy an app with AJP

Tomcat 8.5 can use AJP to serve applications in EasyApache 4. For more information, read our Tomcat Proxies documentation. 

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. 

In EasyApache 3, Tomcat existed as a shared service and all applications ran as the tomcat user. The server created a container within a shared server.xml file.

In EasyApache 4, Tomcat runs as a per-user private instance and allows the user to configure their instance themselves. Tomcat runs as the individual user, rather than as the tomcat user. This increases security and places management of the Tomcat instance in the user's control, but may affect your server's performance due to the memory requirements. For more information, read our Tomcat Private Instances documentation. 

For more information about managing services in Tomcat, read our The cpuser_service_manager script and the Ubic subsystem documentation. 

EasyApache 4 provides the mod_proxy_ajp  Apache module rather than the mod_jk connector. 

Additional documentation