Tomcat

Tomcat

Web server software

·

3 min read

Table of contents

No heading

No headings in the article.

Introduction

It is open source web container used to deploy and run the Java-based web application server developed by ASF- Apache Software Foundation

#We can only deploy war files, not ear files in Tomcat

Apache Tomcat - Apache is the foundation name, and Tomcat is a server name

to run the jar file > -jar jar_filename

For war and ear file > Application servers

For Node JS Software > run the node JS Application

For Python software > run the Python apps

Popular application servers

WebSphere Application Server (WAS) > provided by IBM (paid)

WebSphere Liberty Profile > provided by IBM(paid)

WebLogic >BEA >Oracle (Paid)

JBoss/Wildfly > Redhat >IBM (Open Source) (both war & ear)

Apache Tomcat > Apache Software Foundation (Open Source)(only war)

Search https://tomcat.apache.org/download-80.cgi then you will see this page

we are going to use binary distributions zip file and tar file

Tomcat server Directory structure

  1. bin: binary file

    -startup.sh > MAC/Linux

    -startup.bat

    -shutdown.sh

    -shutdown.bat

    -sh catalina.sh > Start/stop the Tomcat server

    -Catalina.bat

    -version.sh

    -version.bat

  2. conf: configuration files

    -server.xml

    -tomcat-user.xml

  3. Lib:

    -jar files

  4. logs:

    -manager.log

    -hostmanager.log

    -Catalina.out(imp)

    -localhost.log

  5. webapps:

    -The deployed application will be here

  6. work:

    -The application file will be stored here

  7. temp:

    -temporary files

Tomcat server installation

  • pre-requisites: java jdk/jre

  • The Port Number that we should allow is

SSH >22, FTP >21, HTTP >80, HTTPS >443, SMTP >25, MySQL>3306

create an instance on AWS

switch to the root user sudo su - or sudo -i

go to the opt directory cd /opt

sudo apt update to install the version update the package index

apt install default-jre for the default version

apt install wget unzip -y

then copy the zip file link address that is in the binary distribution https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.100/bin/apache-tomcat-8.5.100.zip

paste this link along with the wget command

wgethttps://dlcdn.apache.org/tomcat/tomcat-8/v8.5.100/bin/apache-tomcat-8.5.100.zip

ls

unzipapache-tomcat-8.5.100.zip

give execute permissions chmod u+x *.sh

create a soft link to start and stop the server anywhere

ln -s /opt/apache-tomcat-8.5.100/bin/startup.sh/ to usr/bin/start-tomcat

ln -s /opt/apache-tomcat-8.5.100/bin/shutdown.sh/usr/bin/stop-tomcat

start-tomcat

ps -ef | grep tomcat check tomcat server is running or not

netstat -tunlap to check which port is running

now finally to access ip address:port-number

#before that we have to enable the port in security groups

instance > security >security groups (click on the link) > add rule > all traffic >8080 >anywhere >set

then go and reload it will work

now want to deploy the application war file in the manager app

/opt/apache-tomcat-8.5.100/webapps/manager/META-INF

vi context.xml

we have to comment on two lines that are shown in blue color

now add user

/opt/apache-tomcat-8.5.100/conf

vi tomcat-user.xml add these content in end of the file

to open the host manager

if you clear the cache -> ctrl+shift+delete at the tomcat webserver

to change the port number

go to this dir /opt/apache-tomcat-8.5.100/conf

vi server.xml

insert mode >esc: se nu > line number 69 > i insert mode connecter path change your liked port number > esc: wq! > cd .. > then restart the server (#stop-tomcat, #start-tomcat)

  • cd temp directory contains all the jar file

deploy the application

  • tomcat server >application manager >click on war file upload (upload the war file) > deploy

  • the default port number of any of the servers is:80

  • Apache Tomcat is the web application server where we can deploy war file

  • Apache httpd server it is a web server where we can deploy the static content

diff between web servers and application servers

webserverApplication server
we can deploy static content

static content means: HTML, JavaScript, CSS, images | Can deploy backend-related code and static content like Java.,
means: war, ear | | can be load servers also | |