Table of Contents
PART A
We can install tomcat on cPanel server easily from easyapache 4.
Login to WHM Panel >>> Software >>> EasyApache 4 >>> Then click on “Customize” button present in front of “Currently Installed Packages” >>> Then Click on “Additional Packages” option present at left hand side >>> Select Tomcat and click next >>> Then at Review Page, plz check carefully which packages going to be installed, which packages going to be removed and then only click on “Provision” button.
Before deploying the war file, we need to do some IMP settings on the server like enabling the JAVA support in CloudLinux.
1} We need to add more heap memory in Tomcat which can be done in /opt/cpanel/ea-tomcat85/bin/catalina.sh
export JAVA_OPTS=”-Xms512M -Xmx1024M”
export CATALINA_OPTS=”-Xms512M -Xmx1024M”
{NOTE:Perform below steps only if server has cloudlinux installed on it.}
2} Now we need to enable JAVA support in Cloudlinux
Create /etc/cagefs/conf.d/java.cfg and add proper binary files to it:
vi /etc/cagefs/conf.d/java.cfg
comment=Java-custom
paths=/usr/bin/java, /etc/alternatives/java
3}Update skeleton and remount all:
cagefsctl –force-update
cagefsctl –remount-all
4} Added Tomcat-related rpm’s to CageFS:
cagefsctl –addrpm java-1.8.0-openjdk-headless
cagefsctl –addrpm ea-tomcat85
cagefsctl –addrpm tzdata-java
cagefsctl –force-update
cagefsctl -M
PART B
Before deployin TOMCAT application, we need to activate/enable the tomcat support on cPanel account {Domain}
Login to WHM Panel >>> Software >>> Tomcat Manager >>> Search the cPanel user name for which we want to enable the Tomcat and enable it.
++++++++++++++++++++++++++++++++++++++++
Now Deploy the Tomcat Application using following steps.
1) Build your web app – let’s go with a .war file for example purposes. Rename it to ROOT.war.
2) In your server go to the following location, /home/user-name/ea-tomcat85/webapps
3) Copy your ROOT.war file into the location (Step 2)
4) Go to /home/user-name/ea-tomcat85/conf file. There you should find a server.xml file.
Edit server.xml file and add below lines {Replace “user” with cPanel username}
NOW WE CAN TEST OUR CONFIGURATION
1} Run the following commands, where user represents the username:
su – user
echo “export PATH=$(dirname $(readlink /usr/local/cpanel/3rdparty/bin/perl)):$PATH” >> /home/cpuser/.bashrc
source ~/.bashrc
2}Now edit /home/user-name/ea-tomcat85/conf/server.xml file again and change the following value.
vi server.xml
deployOnStartup=”true”
3}You can Copy cPanel’s test javascript to check whether tomcat is working or not.
cp /opt/cpanel/ea-tomcat85/test.jsp /home/cpuser/ea-tomcat85/webapps/ROOT/
4} Restart Tomcat:
ubic restart ea-tomcat85
5} Check your HTTP connector’s port:
egrep ‘Connector port.*HTTP’ ~/ea-tomcat85/conf/server.xml
Above commands output will look like
6} Now first open Connector port in firewall and browse the website using URL
http://domain.com:10000/test.jsp
NOW IF CLIENT WANTS TO ACCESS HIS TOMCAT APPLICATION WITHOUT USING ANY PORT NUMBER LIKE HTTP://DOMAIN.COM THEN WE NEED TO ENABLE MOD_PROXY CONFIGURATION
1) Use the command vi server.xml to view the server.xml file. Find the Ajp/1.3 connector port. It should look something like this:
Remember the port number is 10001.
OR
root@12548703 ~]# egrep “Connector port.*AJP” /home/CPANEL-USER/ea-tomcat85/conf/server.xml
Output of above command will be like this,
{NOTE: NOW REMEMBER, THERE ARE 2 DIFFERENT CONNECTOR PORT. ONE IS WITH HTTP PROTOCOL AND ANOTHER ONE WITH AJP PROTOCOL. CONNECTOR PORT WITH HTTPD PROTOCOL IS USE TO ACCESS THE TOMCAT APPLICATION USING PORT NUMBER}
2) Now go to the location /etc/apache2/conf.d/userdata/std/2/ and run below command.
mkdir -p cPanel-user/your-domain-name
{Replace “cPanel-user” with actual cPanel username and “your-domain-name” with actual domain name}
6) Now go to following location: /etc/apache2/conf.d/userdata/std/2/cPanel-user/your-domain-name/
Now create a file named custom.conf.
Write the below code:
ProxyPass “/” “ajp://127.0.0.1:10001/”
Finally, save it. “10001” is connector AJP port which we found in server.xml file
This gives your website HTTP access.
7) Now got to the following location: /etc/apache2/conf.d/userdata/ssl/2/
mkdir -p cPanel-user/your-domain-name
{Replace “cPanel-user” with actual cPanel username and “your-domain-name” with actual domain name}
Now go to following location: /etc/apache2/conf.d/userdata/ssl/2/cPanel-user/your-domain-name
Create a file named custom.conf.
Write the below code:
ProxyPass “/” “ajp://127.0.0.1:10001/”
Finally, save it. “10001” is connector AJP port which we found in server.xml file
This gives your server HTTPS access
8) Now you need to rebuild the HTTPD, so use the below command
/scripts/rebuildhttpdconf
And now restart the HTTPD by using the below command:
/scripts/restartsrv_httpd
JUST FOR YOUR INFORMATION,
We can set the heap memory for User in setenv.sh file and location of setenv.sh file is /home/CPANEL-USER/ea-tomcat85/bin/setenv.sh
In order to increase the heap memory, edit setenv.sh file and paste below code in it.
export CATALINA_OPTS=”$CATALINA_OPTS -Xms512m”
export CATALINA_OPTS=”$CATALINA_OPTS -Xmx8192m”
And if you want to increase the heap memory to 1 GB then paste below code in setenv.sh file.
export CATALINA_OPTS=”$CATALINA_OPTS -Xms1g”
export CATALINA_OPTS=”$CATALINA_OPTS -Xmx1g”
JUST MAKE SURE THAT YOU WILL TAKE THE BACKUP OF SETENV.SH FILE BEFORE EDITING IT.
Also read:-
Due to growing digitalization, Email Communication has become the backbone of professional interactions. Yet, surprisingly, many professionals struggle to craft…
As the digital landscape continues to evolve, securing your website has never been more crucial. SSL, or Secure Sockets Layer,…
As a web designer and web developer your experience must have reached to new height, right? Further, you need to…
In today's digital landscape, timing is everything. Whether you're a social media manager, business owner, or content creator, the success…
Are you a website owner? Maintaining the website is the prime concern for any website owner. Yes, it’s equally important…