Setup Tomcat server on Linux

Setup Tomcat server on Linux

  1. Login to Azure portal

  2. Create a VM,

  3. After creating VM, add an inbound rule in VM's network port 8080.

  4. JDK & Tomcat server deployement,

     sudo apt-get update -y
     sudo apt install openjdk-11-jre -y #JDK installation
     cd /opt
     sudo wget  #Will download the tomcat setup from the link
     sudo tar -xvf apache-tomcat-9.0.65.tar.gz  #extract from zip

    Now, we need to change the login credentials of tomcat. Follow the below steps,

     cd /opt/apache-tomcat-9.0.65/conf
     sudo vi tomcat-users.xml

    Now we need to create links for the and to the path /usr/bin/.
    Creating symbolic links to in /usr/bin simplifies starting Tomcat from any directory, enhancing user convenience.

     sudo ln -s /opt/apache-tomcat-9.0.65/bin/ /usr/bin/starttomcat #This links will start the tomcat server
     sudo ln -s /opt/apache-tomcat-9.0.65/bin/ /usr/bin/stopTomcat  #This link will stop the tomcat server

    Now we need to comment-out few commands from the below locations. To comment-out, we need to start with <!-- and end with --> ,

     sudo vi /opt/apache-tomcat-9.0.65/webapps/manager/META-INF/context.xml

     sudo vi /opt/apache-tomcat-9.0.65/webapps/host-manager/META-INF/context.xml

  5. Start the tomcat server,

     sudo starttomcat  # to start tomcat server
     sudo stoptomcat   # to stop tomcat server

    Copy the Public IP of the VM where Tomcat server is running and paste in URL in the below format,


    Now Click on Manage App in the right side below Server Status, It'll ask for username and password. Enter the Username and Password which we created and it'll then open i.e., Username - admin and Password - admin1234,

  6. This is where the application will run. To run application follow below steps,

    • Create *.war/*.jar file out of pom.xml using maven commands,

        mvn clean package 
        mvn package
    • To know about Maven setup click here.

    • After creating *.war/*.jar, Change the location of the file,

        sudo cp target/*.war /opt/apache-tomcat-9.0.65/webapps/
    • Now in URL, copy the public IP and write in below format.

      https://<Public IP>:8080/*
      Replace "*" with appname written with .jar/.war. And App will open.