Apache tomcat is java based and is a web server container for web applications
Let's take a look at how it's installed and deploy a simple html application
ec2 instance: t2.micro
since this java based, java is a pre-requisite
download tomcat tar file, I've used tomcat 9:
wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.86/bin/apache-tomcat-9.0.86.tar.gz
extract the tar file:
tar xvzf apache-tomcat-9.0.86.tar
rename for convinience:
mv apache-tomcat-9.0.86.tar tomcat
enter the tomcat foler where these files are seen among others
bin : has files related to start, stop services, etc
conf : has configuration files including server.xml to change port
webapps : this is where the web applications are deployed
go to bin directory and enable startup.sh
file, this enables the tomcat server in port 8081, enable this in security settings
sh startup.sh
But we can't access it yet, it won't let us:
To enable the service, we should allow all users and configure their credentials.
- Allow all users to access the portal by configuring the details in
context.xml
file in this directory
webapps\manager\META-INF\
find and edit that file
vi context.xml
this is how the default script look like:
under <value
section, allow all users by changing it to this:
allow=".*"
- Add users and configure the username, password
From conf directory, edit tomcat-users.xml
file by pasting this script just above </tomcat-users>
at the bottom
- Restart it by going to
bin
sh startup.sh
sh shutdown.sh
Server should be up, showcasing all the folders
We can upload/deploy artifacts using GUI here
Checkout these two repositories to see how to package, deploy artifacts: Maven, Nexus