This guide explains the steps to install and configure Tomcat 8.5 with private instances on a cPanel server. The instructions are designed for users logged in via SSH as the root user or through WHM’s Terminal interface.
Note: Replace $username with the relevant cPanel account username in the provided commands.
- Install Tomcat RPM:
- Install Required Packages
Run the following command to install the ea-tomcat85 and rng-tools packages:yum install ea-tomcat85 rng-tools -y
- Add Tomcat Support to a cPanel Account
For each cPanel user requiring Tomcat, execute:/scripts/ea-tomcat85 add $username
Verify Tomcat is enabled for the accounts with:
/scripts/ea-tomcat85 list
- Install Required Packages
- Install Ubic:
Ubic manages the private Tomcat instance. Ensure the cPanel user has shell access and write permissions for /home/$username/.bashrc.- Install Ubic
Run the following commands:su - $username
echo “export PATH=$(dirname $(readlink /usr/local/cpanel/3rdparty/bin/perl)):$PATH” >> /home/$username/.bashrc
For CloudLinux Users
Add Java to the CageFS mounts:cagefsctl --addrpm tzdata-java
cagefsctl –force-update
- Verify Ubic Installation:
Check if Ubic is running and Tomcat is enabled for the user:su - $username -s /bin/bash -c 'ubic status ea-tomcat85'
- Install Ubic
- Configure the Tomcat Environment:
- Configure Application Directory:
Modify the <Host> section in the /home/$username/ea-tomcat85/conf/server.xml file. Add the following entry below the autoDeploy, deployOnStartup, and deployXML settings:<Context path="" docBase="webapps/ROOT" reloadable="true"/>
- Verify the Environment:
- Determine the HTTP port:egrep ‘Connector port.*HTTP’ /home/$username/ea-tomcat85/conf/server.xml
- Copy the test JSP file to the ROOT directory:sudo -u $username cp -avp /opt/cpanel/ea-tomcat85/test.jsp /home/$username/ea-tomcat85/webapps/ROOT/
- Restart the Tomcat instance:
su - $username -s /bin/bash -c ‘ubic restart ea-tomcat85’
Access the test JSP file at:
http://yourserverip:$PORT/test.jsp
You should see a page displaying:
Test JSP Page: This is a page to check that .jsp support has been enabled.
- Configure Application Directory:
- Configure ProxyPass for Apache
- Get the AJP Connector Port
Retrieve the AJP port:egrep ‘Connector port.*AJP’ /home/$username/ea-tomcat85/conf/server.xml - Create ProxyPass Include Files
Create an Apache include file for both HTTP and HTTPS:/etc/apache2/conf.d/userdata/std/2_4/$username/$domain.tld/tomcatproxypass.confAdd the following content:<IfModule proxy_ajp_module>
Proxypass “/” “ajp://127.0.0.1:$PORT/”
</IfModule>
Replace $PORT with the AJP port obtained earlier.
- Rebuild and Restart Apache
Apply the configuration:/usr/local/cpanel/scripts/rebuildhttpdconf && /usr/local/cpanel/scripts/restartsrv_httpd - Verify ProxyPass:
Access the test JSP file at:http://yourdomain.tld/test.jsp
You should see the Test JSP Page confirming the successful ProxyPass configuration.
- Get the AJP Connector Port
- Deploy Your Application
- Copy your application files to the following directory:
/home/$username/ea-tomcat85/webapps/ROOT/
- Your application will be accessible at:
http://yourdomain.tld/
- Copy your application files to the following directory:
By following these steps, you can successfully install and configure Tomcat 8.5 with private instances on a cPanel server. If you encounter issues, feel free to contact support.