• google plus

How to Deploy a Web Application Using the Apache Tomcat Manager (Linux)

To deploy a web application to Apache Tomcat you can copy a WAR file to the application base directory, e.g., /var/lib/tomcat7/webapps. This operation of course presupposes we know the application base directory. We could consult server.xml and look up the Host element to determine the directory name. A more straightforward approach is to use the Tomcat manager web application.

To learn how to deploy a web application using the Apache Tomcat manager web application in Linux, follow these 12 steps:

  1. Stop the Tomcat server.
  2. You will need to edit CATALINA_BASE/conf/tomcat-users.xml, e.g., /var/lib/tomcat7/conf/tomcat-users.xml to add credentials to access the Tomcat manager web application.
  3. Add the following XML statements immediately before the root end tag,i.e., </tomcat-users>:
    <role rolename="manager-gui"/>
    <user username="your name" password="your password" roles="manager-gui"/>
    </tomcat-users>
    	
    Replace "your name" and "your password" with a user name and password of your choosing (no embedded spaces).
  4. Save your changes.
  5. You'll need to create a WAR file so that you will have a web application to deploy. The instructions for creating a WAR file were contained in Steps 1 and 2 in the topic . Complete only Steps 1 and 2. If you have already completed that project, delete the WAR file (DemoWebsite.war) and the unpacked folder (DemoWebsite) from CATALINA_BASE/webapps , e.g., /var/lib/tomcat7/webapps.
  6. Start the Tomcat server.
  7. In the address area of your browser, type http://localhost:8080/manager/html and submit that address to the browser.
  8. You will be challenged for credentials. Provide the user name and password you specified in tomcat-users.xml (make sure to provide the correct spelling and case):
    Manager credentials
    Click OK
  9. The manager web page is now displayed. Scroll down until you see the Deploy section:
    Manager deploy
    Note that I have already provided the Context Path (/DemoWebsite) and the WAR URL ((/DemoWebsite/DemoWebsite.war) in the text boxes. Fill in the text boxes as I've done. Then click Deploy.
  10. The manager will indicate that the web site has been deployed:
    Manager web app deployed
  11. In a separate tab in your browser, type http://localhost:8080/DemoWebsite/DateJSP.jsp and submit that address to the browser.
  12. The web page will be displayed verifying successful deployment:
    Demo Website
Author: Stephen Withrow

Stephen has over 30 years' experience in training, development, and consulting in a variety of technology areas including Java, C, C++, XML, JavaScript, AJAX, Tomcat, JBoss, Oracle, and DB2. His background includes design and implementation of business solutions on client/server, Web, and enterprise platforms. Stephen is a published writer in both technical and non-technical endeavors. Stephen received an undergraduate degree in Computer Science and Physics from Florida State University.

About Webucator

Webucator provides instructor-led training to students throughout the US and Canada. We have trained over 90,000 students from over 16,000 organizations on technologies such as Microsoft ASP.NET, Microsoft Office, XML, Windows, Java, Adobe, HTML5, JavaScript, Angular, and much more. Check out our complete course catalog.