Installing Tomcat on EC2 Instance

Let's install Tomcat under the location /opt and make sure you are root.

1) Becoming root

# sudo su

2) Need to install java for making tomcat work properly

# yum install java-1.8* -y

3) Change Directory to /opt

# cd /opt

4) Downloading apache-tomcat files to the directory /opt using wget command, we need to get the download url for the
tar.gz files. The exact step is mentioned in the below image.

# wget https://mirrors.estointernet.in/apache/tomcat/tomcat-8/v8.5.60/bin/apache-tomcat-8.5.60.tar.gz

5) Once the tar.gz file is download under /opt directory we can unzip the tar file

# tar -xvzf apache-tomcat-8.5.60.tar.gz

6) Now we will get a directory "apache-tomcat-8.5.60" the version number may change. inside that directory, you can find on the directory named bin. go inside that directory.

# cd apache-tomcat-8.5.60/bin/

7) Inside this directory (/opt/apache-tomcat-8.5.60/bin/) we can find two files named "startup.sh & shutdown.sh". These two scripts are used to start and stop tomcat in the server. We need to make these two scrips executable using the chmod command then only they will work as needed.

# chmod +x startup.sh

# chmod +x shutdown.sh

8) Once the scrips are given exicutable permission we can run them from the "/opt/apache-tomcat-8.5.60/bin/" location or by giving the absalute path.

#  pwd
/opt/tomcat/bin

# ./startup.sh    For start tomcat    

(if using absalute path use this /opt/tomcat/bin/startup.sh)

# ./shutdown.sh   For stop tomcat  

(if using absalute path use this /opt/tomcat/bin/shutdown.sh)