How to install Tomcat from EasyApache
The Apache Tomcat is actually a server and a servlet container, it enables a webserver to handle aggressive Java-based web content using the HTTP protocol.
The apache is a traditional web server, optimized for handling static and dynamic web content (very often PHP-based), its absence the ability to manage Java Servlets and JSP. The Tomcat is almost totally geared towards Java-based content. Tomcat was originally developed as a means to provide the JSP functionality that Apache absence.
In order to install Tomcat from EasyApache, first, we need to Enable Tomcat 8.5 support for a cPanel account.
After enabling Tomcat from the cPanel Tomcat Manager panel, create an A folder to host tomcat code “ea-tomcat85” will be created under the cPanel account home directory.
Once we created the folder “ea-tomcat85” under the cPanel account home directory, then Configure the application by adding the below line to
/home/cpuser/ea-tomcat85/conf/server.xml under section <Host>.
<Context path=”/” docBase=”/home/cpuser/ea-tomcat85/webapps/ROOT/”> </Context>
We can test the configuration by following the below-provided steps.
su – cpuser
echo “export PATH=$(dirname $(readlink /usr/local/cpanel/3rdparty/bin/perl)):$PATH” >> /home/cpuser/.bashrc
source ~/.bashrc
Edit /home/cpuser/ea-tomcat85/conf/server.xml, look for deployOnStartup under <Host> section. Then, change to following value
deployOnStartup=”true”
cp /opt/cpanel/ea-tomcat85/test.jsp /home/cpuser/ea-tomcat85/webapps/ROOT/
Then Restart Tomcat service,
ubic stop ea-tomcat85
ubic start ea-tomcat85
ubic status ea-tomcat85
To check the HTTP connector’s port:
egrep ‘Connector port.*HTTP’ /home/cpuser/ea-tomcat85/conf/server.xml
Once you have verified the connection port, then you can browse from URL http://yourwebsitename:10002/test.jsp
We can configure the SSL for the site by following the below-provided steps.
Create a new port for SSL site.
/scripts/cpuser_port_authority list cpusername
/scripts/cpuser_port_authority give tomcatmar 1 –service=ea-tomcat85
This command creates a new port 10004 which will be used for the tomcat SSL port. Export PEM key to Java Keystore ( Java SSL name ) by using cPanel generated SSL key.
openssl pkcs12 -export -in combined_crt_ca_key -inkey private.key -out keystore -name domain.com -passin pass:password -passout pass:password
Opened /home/cpuser/ea-tomcat85/conf/server.xml, right below the line which begins with “<Connector port=”10001″ protocol=”HTTP/1.1″ connectionTimeout=”20000″ xpoweredBy=”false”/>”, adding below line
<Connector port=”10004” protocol=”org.apache.coyote.http11.Http11Protocol” SSLEnabled=”true” scheme=”https” secure=”true” sslProtocol=”TLS”
keystoreFile=”/home/cpuser/ea-tomcat85/conf/ssl/kestorefile” keystorePass=”password”/>
Restart Tomcat service.
Once you restart the Tomcat service, you can browse with HTTPS URL.
We can proxy the Tomcat to Apache by following the below-provided steps.
Uncomment the below line from the apache configuration file.
In order to customize this VirtualHost, we can use an include file at the following location Include “/etc/apache2/conf.d/userdata/std/2_4/cpuser/domain.com/*.conf”
Then create a file name tomcatproxypass.conf or any file name, insert below the line.
<IfModule proxy_ajp_module>
ProxyPass “/” “ajp://127.0.0.1:10003/”
</IfModule>
Now can browse the URL like below,
Tomcat port
http://tomcat.example.com:10002/test.jsp
https://tomcat.example.com:10004/test.jsp
Apache proxy port
http://tomcat.example.com/test.jsp
https://tomcat.example.com/test.jsp