Deploying Tomcat application using Podman on a cPanel server usually requires a variety of configuration steps. While there are several container management tools available, Podman offers a simpler and daemon-free approach to managing containers.
Step-by-Step Deployment Guide
Step 1: Install Tomcat with Podman
Start by accessing the Terminal on your cPanel. To install Tomcat via Podman, execute the following command:
/scripts/ea-podman install ea-tomcat101
This command install Tomcat and creates a directory named like ea-tomcat101.username.02 within /ea-podman.d/ directory.
Step 2: Upload Your WAR File
Now, navigate to the newly created Tomcat directory:
cd /home/username/ea-podman.d/ea-tomcat101.username.02
Inside this directory, locate the webapps folder and upload your .war file there. Make sure the file is named ROOT.war to ensure it’s deployed correctly.
Step 3: Modify Tomcat Configuration
To ensure your application is deployed on startup, navigate to the conf file
cd /home/username/ea-podman.d/ea-tomcat101.username.02/conf
open the server.xml file for editing. Look for the following line:
<Host name=”localhost” appBase=”webapps” unpackWARs=”false” autoDeploy=”false” deployOnStartup=”false” deployXML=”false”>
Change the false values to true, so it looks like this:
<Host name=”localhost” appBase=”webapps” unpackWARs=”true” autoDeploy=”true” deployOnStartup=”true” deployXML=”true”>
Once you’ve made the change, save and close the file.
Step 4: Restart Tomcat
To apply the changes, restart the Tomcat service by running the following command:
/scripts/ea-podman restart ea-tomcat101.username.02
Upon restarting, your .war file will automatically deploy into the webapps folder, and a directory named ROOT will be created for your application.
Step 5: Configure Apache
Next, log into your server via SSH as the root user and modify the Apache configuration file located at /usr/local/apache/conf/httpd.conf. Search for the domain example.com and uncomment the following lines in the virtual host entries for ports 81 and 444:
Include "/etc/apache2/conf.d/userdata/std/2_4/username/example.com/*.conf"
Include "/etc/apache2/conf.d/userdata/ssl/2_4/username/example.com/*.conf"
Once you’ve made these changes, save the file.
Step 6: Create Necessary Directories
Now, as the root user, create the following directories:
mkdir -p /etc/apache2/conf.d/userdata/std/2_4/username/example.com
mkdir -p /etc/apache2/conf.d/userdata/ssl/2_4/username/example.com
Step 7: Add Proxy Configuration
Inside both of the newly created directories, create a file named proxy.conf and add the following code:
<IfModule proxy_ajp_module>
ProxyPass "/" "ajp://127.0.0.1:10003/"
</IfModule>
To determine the correct port, run the following command:
podman ps
Step 8: Restart Apache
Finally, restart Apache to apply all your changes by running:
systemctl restart httpd
Conclusion
Your Tomcat application should now be successfully deployed and accessible on your cPanel server.
For assistance with deploying a Tomcat application using Podman on a cPanel server, contact our expert support team today for seamless guidance.