cPanelResources

Tutorial Installation and configuration of ea-Tomcat85

Tomcat Installation Guide

Contents:
  1. Introduction
  2. Installing Tomcat
  3. Installing Ubic
  4. Tomcat Environment Configuration
  5. Installing your site

I. Introduction

In this guide, we will walk through the process of ensuring that you, and your users, can make use of your newly installed Tomcat software.

This guide walks through the process of installing Tomcat 8.5 with private instances. It distills the installation process outlined in our Tomcat Installation Documentation, the information in our Tomcat Private Instances Documentation, and the installation of the Ubic software.

For this guide, all instructions are provided as though you were logged into the server through SSH as the root user, or are using WHM's Terminal (WHM > Server Configuration > Terminal).

Command line tip: In the examples provided below, $username represents the username associated with the individual cPanel account. For example, if the cPanel account's username is example123, then the following example:

/home/$username/.bashrc

Should look like this in actual use:

/home/example123/.bashrc


II. Installing Tomcat



1. Install the Tomcat RPM

First, we need to install the ea-tomcat85 and rng-tools packages. The command below will accomplish this quickly:
Code:
yum install ea-tomcat85 rng-tools -y

2. Add Tomcat Support to an account

Next, we need to add support for Tomcat to the account(s) that will need it. Use the command below, replicating for each user that requires Tomcat:
Code:
/scripts/ea-tomcat85 add $username
Once the above is complete, you can verify that Tomcat is enabled for the accounts with
Code:
/scripts/ea-tomcat85 list

III. Installing Ubic



1. Installation

Installation of Ubic for any given cPanel user is quite straight forward. It requires the cPanel user to have shell access to the server and write permissions to the users /home/$username/.bashrc file. The below command can be pasted into the shell/terminal while logged with root access after replacing $username with the correct username.

Code:
su - $username
echo "export PATH=$(dirname $(readlink /usr/local/cpanel/3rdparty/bin/perl)):$PATH" >> /home/$username/.bashrc
Note: You can skip the "su" command if you access SSH directly as the cPanel user.


a. CloudLinux Considerations

If you are using CloudLinux, then you will also need to run the following commands (from the root level) to add Java to the CageFS mounts:

Code:
cagefsctl --addrpm tzdata-java
cagefsctl --force-update

2. Verification/Testing

Once installed you can test that Ubic is functioning, and that Tomcat is installed/enabled for the user with this command (from the root level):

Code:
su - $username -s /bin/bash -c 'ubic status ea-tomcat85'


IV. Tomcat Environment Configuration


Configuration of the Tomcat environment is the most involved portion of this process. The steps outlined below can be used to configure the environment properly. Please be aware that the ports noted below are examples, and your specific ports may vary.


1. Configure the application directory

To enable the ROOT webapp directory for testing, add the following entry to the <Host> section in the /home/$username/ea-tomcat85/conf/server.xml file. This section begins with the deploy options, so this can be placed below the line containing the autoDeploy, deployOnStartup, and deployXML settings. Here's an example of how this should look, with the entry you must add displayed in bold text:

<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="false" deployOnStartup="false" deployXML="false">
<Context path="/" docBase="/home/$username/ea-tomcat85/webapps/ROOT/">
</Context>

<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--

2. Verify the environment

To verify that the environment is functional, we recommend you copy our test.jsp and attempt to call it directly, before making any changes that may affect Apache's configuration.

You'll need to know the port to test against. It can be obtained using the following command:

Code:
egrep 'Connector port.*HTTP' /home/$username/ea-tomcat85/conf/server.xml
In order to copy the test script you would use the below command:

Code:
sudo -u $username cp -avp /opt/cpanel/ea-tomcat85/test.jsp /home/$username/ea-tomcat85/webapps/ROOT/
Once done restart the Private Tomcat Instance for the user:

Code:
su - $username -s /bin/bash -c 'ubic restart ea-tomcat85'
To confirm test.jsp is working, access "http://yourserverip:$PORT/test.jsp" with your favorite method, where $PORT is the port obtained previously. You should receive a page containing the following:

Test JSP Page
This is a page to verify that .jsp support has been enabled
To learn about managing port access for users, see the document below:



3. Configure Proxypass


First, you'll need to obtain the AJP connector port so that you can properly configure the ProxyPass directive. This command will return the port information:

Code:
egrep 'Connector port.*AJP' /home/$username/ea-tomcat85/conf/server.xml
Once you have obtained the port you can then create a ProxyPass Apache include file. Remember to perform this action twice. Once for http (std) and once for https (ssl). This uses the same methodology as our Apache VHost Includes. The include path for http (std) would be:

/etc/apache2/conf.d/userdata/std/2_4/$username/$domain.tld/tomcatproxypass.conf
and the file would look similar to this:

Code:
<IfModule proxy_ajp_module>
  ProxyPass "/" "ajp://127.0.0.1:$PORT/"
</IfModule>
where $PORT is the port value returned from the earlier command.

After creating the include files you'll need to rebuild the Apache configuration, and restart the service. The pair of commands noted below will accomplish this quickly for you:

Code:
/usr/local/cpanel/scripts/rebuildhttpdconf && /usr/local/cpanel/scripts/restartsrv_httpd
Finally, confirm that the ProxyPass include is working by loading up "http://yourdomain.tld/test.jsp" in your favorite browser. As before, you should receive the following output:

Test JSP Page
This is a page to verify that .jsp support has been enabled

V. Installing your site


If you've made it this far successfully you're ready to install your application. Simply copy the application files into /home/$username/ea-tomcat85/webapps/ROOT/ and your application will load at yourdomain.tld/.

Additional Questions/Feedback
Feel free to click on the Discussion tab to let us know if you have any questions or feedback about the information in this tutorial.
Author
cPanelResources
Views
623
First release
Last update