DevOps 3.3: App Setup

"Configuring Your App: DevOps 3.3 - Smooth Application Setup with Tomcat"

ยท

2 min read

DevOps 3.3: App Setup

TOMCAT SETUP:

Login to the Tomcat VM:

  1. Login to the Tomcat vm

     vagrant ssh app01
    
  2. Verify Hosts entry, if entries missing update them with IP and hostnames using cat /etc/hosts .

  3. Update the OS to the latest patches using yum update -y .

  4. Set Repository

    using yum install epel-release -y .

  5. Install dependencies dnf -y install java-11-openjdk java-11-openjdk-devel .

    dnf install git maven wget -y

  6. Change dir to /tmp

    cd /tmp/

  7. Download the Tomcat package wget https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.75/bin/apache-tomcat-9.0.75.tar.gz

  8. Now extract it using tar xzvf apache-tomcat-9.0.75.tar.gz .

  9. Add tomcat user useradd --home-dir /usr/local/tomcat --shell /sbin/nologin tomcat .

  10. Copy data to tomcat home dir using cp -r /tmp/apache-tomcat-9.0.75/* /usr/local/tomcat/ .

  11. Create Tomcat service file

    vi /etc/systemd/system/tomcat.service .

  12. Update the file with the below content

    [Unit]
    Description=Tomcat
    After=network.target
    [Service]
    User=tomcat
    WorkingDirectory=/usr/local/tomcat
    Environment=JRE_HOME=/usr/lib/jvm/jre
    Environment=JAVA_HOME=/usr/lib/jvm/jre
    Environment=CATALINA_HOME=/usr/local/tomcat
    Environment=CATALINE_BASE=/usr/local/tomcat
    ExecStart=/usr/local/tomcat/bin/catalina.sh run
    ExecStop=/usr/local/tomcat/bin/shutdown.sh
    SyslogIdentifier=tomcat-%i
    [Install]
    WantedBy=multi-user.target
    
  13. Reload the files systemctl daemon-reload .

  14. Start and enable the service

    # systemctl start tomcat
    # systemctl enable tomcat
    
  15. 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
    

CODE BUILD & DEPLOY (app01)

  1. Download Source code

    git clone -b main https://github.com/saswatsam786/devops-project-local

  2. Update configuration

     # cd vprofile-project
     # vim src/main/resources/application.properties
     # Update file with backend server details
    
  3. Build code

  1. mvn install run it.

  2. Deploy artifact

     systemctl stop tomcat
    
  3. Deploy artifact

     # systemctl stop tomcat
    
     # rm -rf /usr/local/tomcat/webapps/ROOT*
     # cp target/vprofile-v2.war /usr/local/tomcat/webapps/ROOT.war
     # systemctl start tomcat
     # chown tomcat.tomcat /usr/local/tomcat/webapps -R
    

Next, We WILL SETUP THE NGINX!!!

Did you find this article valuable?

Support Chronicles of Tech ๐Ÿ“š๐Ÿ’ป by becoming a sponsor. Any amount is appreciated!

ย