Step by Step guide to install Apache Tomcat on Amazon Linux
Install Tomcat Webserver for running Java Application on Amazon Linux
2 min readFeb 28, 2022
Prerequisites
- Amazon Linux Machine with a minimum of 2GB RAM.
- Needs to open 8080 on EC2 Security Group (8080 for Tomcat Default Port).
Steps to install and configure Tomcat
- Install Java on Machine
- Install Tomcat on Machine
- Add Execute Permission to startup.sh & shutdown.sh
- Create link files for Tomcat Server up and Down
- Change Settings to Manage Tomcat
- Update user information in tomcat-users.xml
Install Java
yum install java-1.8*
Install Tomcat
sudo su -
cd /
cd /opt
#Download tomcat binary
wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.55/bin/apache-tomcat-9.0.55.tar.gz
#unzip tomcat binary
tar -zvxf apache-tomcat-9.0.55.tar.gz
Add Execute Permission to startup.sh & shutdown.sh
cd apache-tomcat-9.0.55
cd bin
chmod +x startup.sh
chmod +x shutdown.sh
Create link files for Tomcat Server up and Down
ln -s /opt/apache-tomcat-9.0.55/bin/startup.sh /usr/local/bin/tomcatupln -s /opt/apache-tomcat-9.0.55/bin/shutdown.sh /usr/local/bin/tomcatdowntomcatup
Change Settings to Manage Tomcat
cd apache-tomcat-9.0.55find -name context.xml./conf/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 filesvi ./webapps/examples/META-INF/context.xml
vi ./webapps/host-manager/META-INF/context.xml
vi ./webapps/manager/META-INF/context.xml
Update user information in tomcat-users.xml
cd apache-tomcat-9.0.55
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="s3cret" roles="manager-gui"/>
Access Tomcat Web Interface
http://server_ip:8080/
You should see Tomcat welcome page.
At this point, Apache Tomcat was installed successfully.
Conclusion
In this tutorial, we’ve installed Apache Tomcat on Amazon Linux.