Thursday, February 23, 2023

Tomcat installation and configuration on linux server

1. Create one EC2 instance: 

2.Login on ec2 instance and swith to root user.

Command: #sudo su -

3.Install java

Command:  #yum install java  

4. Set JAVA_HOME

Command: #export JAVA_HOME=/usr/lib/jvm/java-17-amazon-corretto.x86_64

5. check java home is setup succesfully or not

 Command: #echo $JAVA_HOME

/usr/lib/jvm/java-17-amazon-corretto.x86_64

6. Set path

command: #export  PATH=$PATH:$JAVA_HOME

7. Check java home addedd succesfully in path or not

Commnad: # echo $PATH

O/P:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/lib/jvm/java-17-amazon-corretto.x86_64

-----------------------

8. Create middleware directory under opt

mkdir /opt/middleware


9. Go to middleware directory and download apache tomcat.

#cd /opt/middleware

#wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.72/bin/apache-tomcat-9.0.72.tar.gz


10. Extract tomcat and add admin user in  tomcat-users.xml file

#tar -xvf apache-tomcat-9.0.72.tar.gz

cd apache-tomcat-9.0.72/conf

#ls -l

vi  tomcat-users.xml

<role rolename="tomcat"/>

<role rolename="manager-gui"/>

<role rolename="admin-gui"/>

<role rolename="manager-script"/>

<role rolename="manager-jmx"/>

<user username="admin" password="admin" roles="tomcat,manager-gui,admin-gui,manager-script,manager-jmx"/>


---

11.Go to /opt/middleware/apache-tomcat-9.0.72/webapps/manager/META-INF and /opt/middleware/apache-tomcat-9.0.72/webapps/host-manager/META-INF and comment out below content

 <!--

  <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"/> -->


12. Start tomcat

[root@ip-172-31-15-218 bin]# pwd

/opt/middleware/apache-tomcat-9.0.72/bin

[root@ip-172-31-15-218 bin]# ./startup.sh

#ps -ef|grep java 

#ps -ef|grep tomcat


13. Deploy application on tomcat.

[root@ip-172-31-15-218 webapps]# pwd

/opt/middleware/apache-tomcat-9.0.72/webapps

#wget https://github.com/AKSarav/SampleWebApp/raw/master/dist/SampleWebApp.war

Note : context path is SampleWebApp

#ls -l  ==> you will see your war and respective directory.


14.go browser and access your application: 

http://public-ip:8080/SampleWebApp




No comments:

Post a Comment

Sample Game App Deployment on EKS cluster

 https://padmakshi.medium.com/setting-up-an-eks-cluster-and-deploying-a-game-application-a-step-by-step-guide-08790e0be117