0% found this document useful (0 votes)
39 views

Apache Tomcat Setup in AWS Cloud

The document describes how to install and configure the Apache Tomcat web server on an Amazon Linux EC2 instance. It provides instructions for downloading and extracting Tomcat, configuring security groups, starting the Tomcat service, and deploying a sample Maven web application.

Uploaded by

Partho Protim
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Apache Tomcat Setup in AWS Cloud

The document describes how to install and configure the Apache Tomcat web server on an Amazon Linux EC2 instance. It provides instructions for downloading and extracting Tomcat, configuring security groups, starting the Tomcat service, and deploying a sample Maven web application.

Uploaded by

Partho Protim
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

+++++++++++++++++++++

Apache Tomact Server


++++++++++++++++++++

=> Apache Tomcat is a web server

=> Apache Tomcat is used to run Java Web Applications

=> Apache Tomcat is free & open source

=> Apache Tomcat runs on 8080 port bydefault (we can change that port)

Apache Tomcat Folder Structure


++++++++++++++++++++++++++++++

bin : It contains commands to start and stop tomcat server

conf : It contains configuration files

lib : It contains libraries (jar files)

logs : It contains server log files

temp : Temp files will be created here (we can delete them)

webapps : This is called as deployment folder

Note: We will keep war file in webapps folder for deployment

Working with Apache Tomact in Linux


++++++++++++++++++++++++++++++++++++

-> Login into AWS Management Console

-> Create EC2 Instance (Amazon Linux AMI)

-> Connect to EC2 instance using MobaXterm / Putty

-> install java software using below command

$ sudo yum install java-1.8.0-openjdk

-> Verify the version of java installed in our machine

$ java -version

Note: If we have multiple java versions installed then we can switch to particular
version using below command

$ alternatives --config java

-> We can download apache tomcat from official website

URL : https://tomcat.apache.org/download-90.cgi
-> We can find apache tomcat urls to download in official website downloads page

-> Copy the URL of tar file and execute below command in linux machine

$ wget <tomact-tar-file-url>

Note: I am using

"https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.63/bin/apache-tomcat-
9.0.63.tar.gz"

-> After tomact tar file got downloaded then extract Tomcat Tar file using below
command

$ tar -xvf <tomact-tar-file-name>

-> Go inside tomcat folder and see folder structure

$ cd tomact-folder
$ ls -ltr

-> Go to tomact bin directory and run tomact server

$ cd bin
$ ./startup.sh

Note: Tomcat Server runs on 8080 port by default. Enable this port in security
group as custom tcp

Type : Custom TCP


Protoal : TCP
Port Range: 8080
Source : Custom (0.0.0.0/0)

-> Access Tomact server from your browser

URL : http://EC2-VM-Public-IP:8080/

Note: It should open tomact server home page.

-----------------------------------------------------------------------------------
---------------

=> By default the Host Manager is only accessible from a browser running on the
same machine as Tomcat. If you wish to modify this restriction, you'll need to edit
the Host Manager's context.xml file.

=> File Location : <tomcat>/webapps/manager/META-INF/context.xml

=> In Manager context.xml file, change <Valve> section like below (allow attribute
value changed)

<Context antiResourceLocking="false" privileged="true" >


<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow=".*" />
</Context>

Add tomact users in "tomact-folder/conf/tomact-users.xml" file like below


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<role rolename="manager-gui" />
<user username="tomcat" password="tomcat" roles="manager-gui" />
<role rolename="admin-gui" />
<user username="admin" password="admin" roles="manager-gui,admin-gui"/>

-> Stop the tomact server and start it

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
We can change tomcat server default port in tomact/conf/server.xml file
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

-> When we change tomact port number in server.xml file then we have to enable that
port in Security Group which is associated with our EC2 instance.

+++++++++++++++++++++++++++++++++++++++++++++++++++++++
Steps to display Maven Web Application in Tomcat Server
+++++++++++++++++++++++++++++++++++++++++++++++++++++++

1) Create Maven Web application

2) Edit "index.jsp" file like below (File Location : project-folder\src\main\


webapp)

<html>
<body>
<h1><font color='red'>Welcome to Ashok IT..!!<font></h1>
<h2>Learn Here.. Lead Anywhere..!! </h2>

<a href="https://ashokitech.com/online-training-schedules">Click Here To See


Training Schedules</a>
</body>
</html>

3) Package maven web application as war file using maven goals

$ mvn clean package

4) Go to Tomcat Server Admin Dashboard and click on "Manager App"

5) Select War file to upload and click on 'deploy' button

6) War file will be deployed and it will display in applications

7) Click on Application Path (It will open the application in browser)

Conclusion
+++++++++++
-> Stop Apache Tomact Server

-> Stop Ec2 instance


-----------------------------------------------------------------------------------
---------------

You might also like