Day 11: Install and Configure Tomcat Server

Question:

The Nautilus application development team recently finished the beta version of one of their Java-based applications, which they are planning to deploy on one of the app servers in Stratos DC. After an internal team meeting, they have decided to use the tomcat application server. Based on the requirements mentioned below complete the task:

a. Install `tomcat` server on `App Server 1`.

b. Configure it to run on port `5000`.

c. There is a `ROOT.war` file on `Jump host` at location `/tmp`.

Deploy it on this tomcat server and make sure the webpage works directly on base URL i.e curl http://stapp01:5000


Solution:

# SSH to app server 1
ssh tony@stapp01

# Install Tomcat
sudo dnf install tomcat tomcat-admin-webapps -y

# Change port
nano vi /etc/tomcat/server.xml
<Connector port="5000" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443"
               maxParameterCount="1000"
               />

# Start tomcat service
sudo systemctl restart tomcat

# Search for Tomcat webapps directory in the file system
ps aux | grep tomcat
tomcat     ...   /usr/share/tomcat/bin/bootstrap.jar:/usr/share/tomcat/

# We need to upload the war file to this location
ls -l /usr/share/tomcat/webapps/
total 8
drwxr-xr-x 6 root tomcat 4096 Nov 10 10:26 host-manager
drwxr-xr-x 6 root tomcat 4096 Nov 10 10:26 manager

# exit to jump host
exit

Now to deploy the war file from jump host to the app server 1 /usr/share/tomcat/webapps/

# Use scp to transfer file from jump host to app server 1
scp /tmp/ROOT.war tony@stapp01:/tmp

# Reason I copied to app server /tmp is becauseyou need sudo permissions to copy a file to /usr/share/tomcat/webapps/

# SSH to app server 1
ssh tony@stapp01

# Copy from /tmp to /usr/share/tomcat/webapps/ with sudo permissions
sudo cp /tmp/ROOT.war /usr/share/tomcat/webapps/

# exit to jump host
exit

Note test with curl:

curl http://stapp01:5000
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <title>SampleWebApp</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
        <h2>Welcome to xFusionCorp Industries!</h2>
        <br>
    
    </body>
</html>

By shafdo

Leave a Reply

Your email address will not be published. Required fields are marked *