In this tutorial I will show you how you install Tomcat Server in your AWS Linux.
- AWS Account and login to AWS Console, here.
- Create an AWS EC2 with Amazon Linux 2 AMI instance and Instance type between *micro-*small.
- Install Java JDK on Amazon Linux, here.
1) Install Tomcat:
Go to tomcat.apache.org/download and find the latest stable version of tomcat, as this tutorial wrote, tomcat 9.0.41 is the latest stable we can use. Get the URL address of "tar.gz" file below;
Go in your in your EC2 instance and remember log as "sudo" 1st before you execute below command:
2) Extract TAR file
Go /usr/local or /usr/shared and then extract the TAR file you downloaded in previous step.
tar -xvf /root/apache-tomcat-9.0.41.tar.gz
3) Rename the Tomcat
Rename tomcat to simplest name so easy for us to maintain in later stage.
mv apache-tomcat-9.0.41 tomcat9
After that your "tomcat9" will look like below;
4) Add User for Tomcat
useradd -r tomcat
5) Give User Permission
Give permission user to tomcat9 folder:
chown -R tomcat:tomcat /usr/local/tomcat9
6) Create Tomcat Service
Copy below script for your Tomcat Service file
sudo tee /etc/systemd/system/tomcat.service<<EOF [Unit] Description=Tomcat Server After=syslog.target network.target [Service] Type=forking User=tomcat Group=tomcat Environment=CATALINA_HOME=/usr/local/tomcat9 Environment=CATALINA_BASE=/usr/local/tomcat9 Environment=CATALINA_PID=/usr/local/tomcat9/temp/tomcat.pid ExecStart=/usr/local/tomcat9/bin/catalina.sh start ExecStop=/usr/local/tomcat9/bin/catalina.sh stop RestartSec=12 Restart=always [Install] WantedBy=multi-user.target EOF
7) Enable and start tomcat service:
#Reload tomcat service sudo systemctl daemon-reload #Restart/Start tomcat service sudo systemctl start tomcat #Check tomcat service status systemctl status tomcat.service
8) Check Tomcat Service and Host-Manager(GUI)
Finally we check on our browser the Tomcat Server GUI via http://[AWS EC2 Public IP]:8080
- We have created an AWS Instance with Amazon Linux OS
- We installed Java JDK 11 for tomcat dependency.
- Installed Tomcat Server in our EC2 instance.
- We able successfully accessed Tomcat Server Host-Manager(GUI) via browser.