- Apache Tomcat, commonly referred to as Tomcat it is developed using the Java programming language.
- Apache Tomcat is an open-source web server and servlet container used for hosting Java web applications.
- It provides an environment to run Java Servlets and JavaServer Pages (JSPs) and is known for its simplicity and lightweight nature.
- Apache Tomcat runs on port 8080 by default, so port 8080 must be open on EC2 Security Group.
- Java to be installed it can be JDK (Java Development Kit) or JRE (Java Runtime Environment)
- Version of Java to be installed depends upon Tomcat version.
- You can look for it here https://tomcat.apache.org/whichversion.html
- The RAM and hard disk requirements for Apache Tomcat can vary depending on the specific version of Tomcat, the size and complexity of the applications being deployed, and the expected workload.
- For basic testing or development purposes, a minimum of 1 GB of RAM is typically sufficient.
- For small-scale or low-traffic production environments, a minimum of 2-4 GB of RAM is recommended.
- For medium to large-scale deployments or high-traffic environments, you should consider allocating 8 GB or more of RAM.
- The exact amount will depend on factors such as the number of concurrent users, the size and complexity of deployed applications, and any additional services running on the server.
- The base installation of Apache Tomcat requires around 200-300 MB of disk space.
- Additional disk space will be needed for storing web applications, logs, and any other data generated by Tomcat.
- The amount of disk space required will depend on the size and number of deployed applications and the volume of log data generated.
I am going with existing keypair, if you dont have one create new one:

Add new Inbound Security group rule to add 8080 port:

Check the summary if everything is fine launch instance:

you can see instance running shortly:

- Connect to the instance and switch to root user.
- I am planning to install Tomcat-9 so Supported Java Versions are 8 or later. reffer https://tomcat.apache.org/whichversion.html
amazon-linux-extras install java-openjdk11 -y
java --version
sudo su -
cd /
cd /opt
### Download tomcat binary
wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.75/bin/apache-tomcat-9.0.75.zip
### unzip tomcat binary
unzip https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.75/bin/apache-tomcat-9.0.75.zip
### for convenience rename apache-tomcat-9.0.75 to tomcat.
mv apache-tomcat-9.0.75 tomcat
- Tomcat Binary files reffer page: https://tomcat.apache.org/download-90.cgi

cd /opt/tomcat/bin
chmod +x catalina.sh startup.sh shutdown.sh
we create softlink to start and stop Tomcat service from anywhere. if you Don't want to create softlink then you can start and stop Tomcat service by going to /opt/tomcat/bin directory.
ln -s /opt/tomcat/bin/startup.sh /usr/local/bin/tomcatup
ln -s /opt/tomcat/bin/shutdown.sh /usr/local/bin/tomcatdown
tomcatup
cd /opt/tomcat
cd conf
vi tomcat-users.xml
#Add below lines between <tomcat-users> tag
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<user username="admin" password="admin" roles="manager-gui,manager-script,manager-jmx,manager-status"/>
<user username="deployer" password="deployer" roles="manager-script"/>
<user username="tomcat" password="tomcat" roles="manager-gui"/>
To access the Tomcat Manager App, Server Status, Host Manager you need to comment out value tag in some xml file

If you try to access Tomcat Manager App or Server Status or Host Manager with out doing the required settings then you will get 403 Access Denied Error.

cd /opt/tomcat
find -name context.xml
./conf/context.xml
./webapps/docs/META-INF/context.xml
./webapps/examples/META-INF/context.xml
./webapps/host-manager/META-INF/context.xml
./webapps/manager/META-INF/context.xml
#comment value tag sections in below all files
vi ./webapps/examples/META-INF/context.xml
vi ./webapps/host-manager/META-INF/context.xml
vi ./webapps/manager/META-INF/context.xml
Before Commenting the Value tag

After Commenting out the Value tag

To Apply The Changes Stop and Start the Tomcat Service
tomcatdown
tomcatup
Now we can access the tomcat Manager App, Server Status and Host Manager from web-browser

- Create a tomcat user.
- Give ownership of /opt/tomcat directory to tomcat user.
- Then run tomcat services using tomcat user.
















