How to install Tomcat
You must have
root-level access to install Tomcat.
Tomcat is not available on servers that run CentOS 7, CloudLinux 7, or RHEL 7.
In the following examples,
example.com represents your domain.
Step 1: Install Tomcat
To install Tomcat, select the Tomcat 7 option in the Short Options List stage of WHM's EasyApache 3 interface (Home >> Software >> EasyApache 3.
EasyApache automatically inserts the
mod_jk.so module directive into your Apache configuration.
Step 2: Enable Java servlets on your sites
Enable Java servlets via WHM
To enable Java servlets for a site via WHM, perform the following steps:
Navigate to WHM's Install Servlets interface ( Home >> Account Functions >> Install Servlets).
This option does not appear until you install Tomcat on your server.
- Select the account in the Account Selection table and click Install.
- Navigate to the test the installation.
- You can only add servlet support to domains and subdomains.
- To add servlet support to a parked domain (alias), add servlet support to the primary domain.
- To add servlet support to an addon domain, add servlet support to the associated subdomain.
- You cannot add servlet support to subdomains via WHM. Use the command line interface to add servlet support to subdomains.
Enable Java servlets via CLI
To enable Java servlets for a site via the command line, run the following command as the
To enable Java servlets for a subdomain or addon domain, run the following command on the associated subdomain:
If you enable Java servlets for a domain, cPanel & WHM performs the following actions:
- cPanel & WHM creates a container for the site in the
- cPanel & WHM creates a default
cp_jkmount.conffile for the site.
- cPanel & WHM copies the
jsptest.jspfile into the site’s document root.
To confirm that Java servlets work for the domain, navigate to the
Example output from the
How to remove Tomcat servlets from a site
To remove Tomcat servlets from a site via the command line, run the following script as the
This script removes the container for the site from the
/usr/local/easy/etc/easy-tomcat7/server.xml Tomcat server configuration file, and removes the
cp_jkmount.conf site configuration file from each subdirectory for the domain within the
For example, the script removes
cp_jkmount.conf file from the following directories:
How to deploy Java applications
After you enable Java servlets for a domain, the user can deploy Java applications on their web site. Java distributes many applications in convenient WAR packages that you can easily to install on your server.
For more information on how to deploy Java applications, read our How to Deploy Java Applications documentation.
How to manually deploy a WAR file
To manually deploy a WAR file, put the WAR file into the user's
public_html directory. Once placed, you can access the application through the following address:
Then, add a
JkMount entry for the application in the
You must restart the
httpd daemon to reload the
mod_jk file with the new entry.
ROOT.war does not deploy automatically
ROOT.war does not deploy automatically. The index context of all cPanel & WHM hosts is hardcoded to the
Tomcat will install the following components on your server:
|The Java Development Kit (JDK)|
The vendor RPM determines this location.
|This directory contains the Java Runtime Environment (JRE).|
|The Binary Tomcat Distribution||The ||This distribution is precompiled Java byte code, which Tomcat downloads and extracts. The |
|Apache Tomcat Connectors (mod_jk)||These connectors allow Apache to communicate with Tomcat.|
|cPanel-Provisioned Maintenance Scripts||cPanel & WHM uses these maintenance scripts instead of the Tomcat initialization scripts. They create and remove Tomcat virtual hosts.|
Important Tomcat files and directories
|File name or directory||Description|
|The Tomcat output log.|
The Tomcat error log.
The error log marks errors with the following severity levels:
The following command returns any
Tomcat uses cPanel & WHM's default logging facility, Valve.
Tomcat also uses the CentOS-provided
|Apache's log for the |
Tomcat's options file.
Each argument in the options file is defined on a separate line, parsed, and then passed to
The Tomcat server configuration file directory.
|Configures Virtual Hosts, Connectors, and more. While each instance of Tomcat has its own copy of the |
|The configuration file for the |
|Defines the parameters that Apache uses to communicate with Tomcat workers. For more information on this file, read Apache Tomcat's Apache HTTP Server HowTo documentation.|
The site configuration file. This file exists for each site that uses Tomcat.
Each site with Java Servlets or JavaServer contains a
When EasyApache builds your Apache configuration, it uses the following entry in the
The following is an example of a
For more information on the include file format for Apache, read our Modify Virtualhost Containers with Include Files documentation.