How to Install Apache Tomcat on Control Web Panel (CWP)

Install Apache Tomcat in Control Web Panel - Java Deployment
Install Apache Tomcat in Control Web Panel - Java Deployment

Apache Tomcat is a web server environment for running programs written in the Java programming language. It can serve dynamically generated sites with Servlet and JSP. Tomcat is one of the most popular choices for Java application server deployments. Below we’ll cover how to manage Tomcat on Control Web Panel (CWP).

Install Tomcat on CWP

Follow these steps to install Apache Tomcat.

  1. Log into CWP as an administrator.
  2. On the left, search for and select Tomcat Manager.
  3. Select a Tomcat version to install from the dropdown menu, then Install now. Select Continue in the pop-up window. This will also install the CWP Tomcat engine.
    Install Control Web Panel (CWP) Tomcat server and manager
  4. Upon refresh, you’ll see the Tomcat server status, port number, and version number. To the right, you’ll see that OpenJDK was installed. This is the open-source Java installation with Font Renderer and the latest features. For another OpenJDK version or the proprietary Oracle JRE/JDK, follow our guide on how to install Java on CentOS.
    Control Web Panel (CWP) Tomcat Manager
  5. You should now be able to type “youservername:8080” into your web browser and view the Apache Tomcat default page. If not, ensure that port 8080 is open in your CWP server firewall and try again.
Apache Tomcat 10.0.16

Tomcat in User Panels

If you want to allow regular users to manage Tomcat apps: 

  1. Select the Configurations tab at the top of the Tomcat management section. 
  2. Check the box for Tomcat server available in user panel. You can enable access for all accounts or specific ones.
    Enable Tomcat for CWP user panels
  3. Once you’ve made your decision, select Save user panel options. Now, CWP ends users can access Tomcat apps from Domains > Tomcat Manager. Users currently logged in may need to refresh their browser page to see the new section.

During our testing, Tomcat Manager did not display in user panels. If you experience similar issues, contact the CWP team directly.

Harden Apache Tomcat Server Security

On the default Apache Tomcat version 10.0.16 page, you’ll see an important notice:

“For security, access to the manager webapp is restricted. Users are defined in: $CATALINA_HOME/conf/tomcat-users.xml”

You can edit this file in the CWP terminal or Tomcat Manager. 

Due to an unknown error, we could not use the Tomcat Manager to make these changes quickly. We will cover how to attempt this method on your CWP server and bypass the issue if required.

  1. In CWP Tomcat Manager, click on the Configuration tab.
  2. Under “TomCat server configuration files,” select tomcat-users.xml from the drop-down menu. The XML file will load at the bottom of the page.
  3. Without making any changes, select Save file. If a notification in the upper-right corner states “Success,” this means you’re able to edit the file in the graphical interface. Continue to step 4.

    If an error shows in the upper-right corner stating “Invalid configuration file,” you’ll need to make changes from the terminal emulator. Note the file path to your tomcat-users.xml file. It should resemble “/usr/local/tomcat/tomcat10/conf/tomcat-users.xml.” 

    At the top, select Terminal > Simple Terminal. Or you can log into your CWP server via SSH.

    Edit the file with a text editor:
    nano  /usr/local/tomcat/tomcat10/conf/tomcat-users.xml
  4. On or near line 36 you’ll see two “user username” lines encapsulated between two comment lines (“<!–” and “–>”):
    <user username="admin" password="<must-be-changed>" roles="manager-gui"/>
    <user username="robot" password="<must-be-changed>" roles="manager-script"/>

    Remove the comment lines.
  5. Add “admin-gui” to the admin line as shown below, and update the passwords (and “admin” username to something else if desired).
    <user username="admin" password="StrongPasswrd1" roles="manager-gui,admin-gui"/>
    <user username="robot" password="StrongPasswrd2" roles="manager-script"/>
  6. Add more users to the Tomcat configuration file if necessary, using the same format. You may notice a “tomcat_cwpuser” at the bottom of the file. This is used by CWP to integrate Tomcat with CWP.
  7. If editing the file in Tomcat Manager, select Save file & reload server at the top. If editing the file in the terminal, save changes. Then return to the CWP Tomcat Manager dashboard tab and select Restart server.
  8. You should now be able to log into your Tomcat hosting panel with your new admin credentials at “yourserverhostname:8080/host-manager.”
Apache Tomcat Virtual Host Manager

Access Tomcat Applications 

The Applications tab is where you can deploy and manage Tomcat applications. Installed with the Tomcat server are:

  • Servlet and JSP Examples (/examples)
  • Tomcat Documentation (/docs)
  • Tomcat Host Manager Application (/host-manager)
  • Tomcat Manager Application (/manager)
  • Welcome to Tomcat (/)
Tomcat applications in Control Web Panel (CWP)

The table shows applications’ file path, assigned user, status, and number of sessions running. The action buttons allow you to edit, stop, reload, delete, and expire sessions for an app.

Deploy a Tomcat Application

Follow these steps to deploy Tomcat applications as an admin user.

  1. From the “Applications” tab, select Deploy application at the top.
    Tomcat applications in Control Web Panel (CWP)
  2. Assign a CWP user. Add a user if necessary.
    Add Tomcat application in Control Web Panel (CWP)
  3. Select a domain or subdomain.
  4. Specify a context path.
  5. Select a deployment from the drop-down list (WAR file, XML configuration file, or directory).
  6. Select the necessary file or directory.
  7. Select Save.

Learn about more ways to manage your Control Web Panel server.

Upgrade to VPS Hosting for Peak Performance

Upgrade to InMotion VPS Hosting today for top-notch performance, security, and flexibility, and save up to $2,412 – a faster, stronger hosting solution is just a click away!

check markSSD Storage check markHigh-Availability check markIronclad Security check markPremium Support

VPS Hosting

InMotion Hosting Contributor
InMotion Hosting Contributor Content Writer

InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals!

More Articles by InMotion Hosting

Was this article helpful? Join the conversation!