0% found this document useful (0 votes)
33 views8 pages

Tomcatn

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 8

Apache Tomcat

Apache Tomcat is an open-source implementation of the Java Servlet,


JavaServer Pages, Java Expression Language, and Java WebSocket
technologies. It is one of the most widely adopted application and web
servers in the world today. Tomcat is simple to use and has a robust
ecosystem of add-ons.

Step 1: Install OpenJDK

Tomcat requires Java to be installed. We’ll install OpenJDK , which is the default Java development
and runtime in Ubuntu

The installation of Java is pretty simple

ubuntu@Rushi-Infotech:~$ sudo apt-get update

ubuntu@Rushi-Infotech:~$ sudo apt-get install default-jdk

Step 2: Install Tomcat


ubuntu@Rushi-Infotech:/opt$
https://mirrors.estointernet.in/apache/tomcat/tomcat-9/v9.0.54/bin/apache-tomcat-
9.0.54.tar.gz

output:
ubuntu@Rushi-Infotech:/opt$ sudo wget
https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.54/bin/apache-tomcat-9.0.54.tar.gz

--2021-10-11 16:29:27-- https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.54/bin/apache-tomcat-


9.0.54.tar.gz

Resolving dlcdn.apache.org (dlcdn.apache.org)... 151.101.2.132, 2a04:4e42::644

Connecting to dlcdn.apache.org (dlcdn.apache.org)|151.101.2.132|:443... connected.

HTTP request sent, awaiting response... 200 OK

Length: 11576317 (11M) [application/x-gzip]

Saving to: ‘apache-tomcat-9.0.54.tar.gz’

apache-tomcat-9.0.54.tar.gz 100%
[=============================================================================>]
11.04M --.-KB/s in 0.1s

2021-10-11 16:29:27 (103 MB/s) - ‘apache-tomcat-9.0.54.tar.gz’ saved [11576317/11576317]

Step3: Untar the file by using below command

ubuntu@Rushi-Infotech:/opt$ sudo tar -xvf apache-tomcat-9.0.54.tar.gz

Step4: Rename the directory to apache-tomcat-9.0.54 to tomcat9

ubuntu@Rushi-Infotech:/opt$ sudo mv apache-tomcat-9.0.54 tomcat9


Step5: Enter in to tomcat folder

ubuntu@Rushi-Infotech:/opt$ cd tomcat9/

Note: Switch to root user by using below command

step6:Start the tomcat bu using below commands

root@Rushi-Infotech:/opt/tomcat9# cd bin/

root@Rushi-Infotech:/opt/tomcat9/bin# sh startup.sh

Output as below:
root@Rushi-Infotech:/opt/tomcat9/bin# sh startup.sh

Using CATALINA_BASE: /opt/tomcat9

Using CATALINA_HOME: /opt/tomcat9

Using CATALINA_TMPDIR: /opt/tomcat9/temp

Using JRE_HOME: /usr

Using CLASSPATH: /opt/tomcat9/bin/bootstrap.jar:/opt/tomcat9/bin/tomcat-juli.jar

Using CATALINA_OPTS:

Tomcat started.

Step8:Tomcat Port number is 8080

Acesses the tomcat application from web your public-IP:8080


http://13.233.153.97:8080/
Step9: Resolving 403 error Click on manager app  we can see below output

root@Rushi-Infotech: sudo vi /opt/tomcat9/webapps/manager/META-INF/context.xml


Open the file and make below changes

content look as below

<Context antiResourceLocking="false" privileged="true" >

<CookieProcessor className="org.apache.tomcat.util.http.Rfc6265CookieProcessor"

sameSiteCookies="strict" />

<Valve className="org.apache.catalina.valves.RemoteAddrValve"

allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />

<Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|
String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?
HashMap"/>

</Context>
After modifications file should look as below one:
<Context antiResourceLocking="false" privileged="true" >

<CookieProcessor className="org.apache.tomcat.util.http.Rfc6265CookieProcessor"

sameSiteCookies="strict" />

<Valve className="org.apache.catalina.valves.RemoteAddrValve"

allow=".*" />

<Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|
String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?
HashMap"/>

</Context>

Step10: Now resolving 401 error

Click on manager app  we can see below output


Now adding credentials for weblogin t tomcat, delete existing data from the tomcat-users.xml file
and add the below lines

root@Rushi-Infotech: sudo vi /opt/tomcat9/conf/tomcat-users.xml

Note: delete Existing data and and paste below script

<tomcat-users>

<role rolename="manager-gui"/>

<user username="admin" password="Admin" roles="manager-gui, manager-script, manager-admin,


manager-status"/>

</tomcat-users>

Output of the screenshot should look as below

Save the file and come out of it.


Step11: Tomcat configuration is done deploy the war file under tomcat webapps directory

root@Rushi-Infotech:cd /opt/tomcat9/webapps/

root@Rushi-Infotech: sudo wget https://get.jenkins.io/war-stable/2.303.2/jenkins.war

You might also like