Tomcat Server Serup

What is Tomcat:

 Tomcat receives a request from a client through one of its connectors. For Tomcat we gonna use Centos7 and app01.

 Follow the steps to download Tomcat server.

Login to tomcat server

        vagrant ssh app01

 Verify Hosts entry, if entries missing update the it with IP and hostnames 

     cat /etc/hosts

 Update OS with latest patches  

     yum update -y

 Set Repository 

     yum install epel-release -y 

Install Dependencies 

     yum install java-1.8.0-openjdk -y 

     yum install git maven wget -y 

Change dir to /tmp 

     cd /tmp/ 

Download & Tomcat Package

      wget https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.37/bin/apache-tomcat-8.5.37.tar.gz 

     tar xzvf apache-tomcat-8.5.37.tar.gz

 Add tomcat user

     useradd --home-dir /usr/local/tomcat8 --shell /sbin/nologin tomcat Copy data to tomcat home dir 

     cp -r /tmp/apache-tomcat-8.5.37/* /usr/local/tomcat8/ Make tomcat user owner of tomcat home dir 

     chown -R tomcat.tomcat /usr/local/tomcat8 

Setup systemd for tomcat Update file with following content. 

    vi /etc/systemd/system/tomcat.service 

Enter below command in the vi editor.

[Unit] 

Description=Tomcat 

After=network.target

 [Service] 

User=tomcat

 WorkingDirectory=/usr/local/tomcat8

 Environment=JRE_HOME=/usr/lib/jvm/jre

 Environment=JAVA_HOME=/usr/lib/jvm/jre

 Environment=CATALINA_HOME=/usr/local/tomcat8 Environment=CATALINE_BASE=/usr/local/tomcat8

 ExecStart=/usr/local/tomcat8/bin/catalina.sh run 

ExecStop=/usr/local/tomcat8/bin/shutdown.sh 

SyslogIdentifier=tomcat-%i 

[Install] 

WantedBy=multi-user.target 


Start & Enable Tomcat

     systemctl daemon-reload 

     systemctl start tomcat 

     systemctl enable tomcat 

Enabling the firewall and allowing port 8080 to access the tomcat

      systemctl start firewalld

      systemctl enable firewalld 

     firewall-cmd --get-active-zones 

     firewall-cmd --zone=public --add-port=8080/tcp --permanent

     firewall-cmd --reload 

We install Tomcat Server, Now its time to Deploy.


CODE BUILD & DEPLOY (app01)

We Goann deploy in Tomcat server itself so don't exit from tomcat. Follow the below steps one by one.

Download Source code

    git clone -b local-setup https://github.com/devopshydclub/vprofile-project.git

Update and configuration

   cd vprofile-project

   vim src/main/resources/application.properties

Update file with backend server details Build code Run below command inside the repository (vprofile-project)

        mvn install Deploy artifact

       systemctl stop tomcat

        rm -rf /usr/local/tomcat8/webapps/ROOT*

        cp target/vprofile-v2.war /usr/local/tomcat8/webapps/ROOT.war

         systemctl start tomcat

        chown tomcat.tomcat usr/local/tomcat8/webapps -R

         systemctl restart tomcat

Exit from the root user

Logout from Tomcat web01

Now its time to download Ngnix Server click link to install  Ngnix server