Lab 3: Writing a server.xml

Objective: In this lab, you will write your own server.xml config file from scratch, which is a good skill to know how to do. There are settings in the default server.xml that are not used in production.

  1. Start by creating a backup copy of your configuration file by renaming your current conf/server.xml to server_original.xml.
  2. Using a text editor of your choosing, create a new conf/server.xml file.
  3. Add the <Server> element with a shutdown port of 8005 and a shutdown command of “goodbye”.
  4. Add a <Service> named “MyService”.
  5. Within the Service, add an HTTP connector on port 8080 with maxThreads of 10, a connection timeout of 20 seconds, and a redirect port of 8443.
  6. Also within the Service, add an Engine named “MyEngine” whose defaultHost is “localhost”.
  7. Within the Engine add a <Host> named “localhost” whose appBase is the webapps folder. Set unpackWARs and autoDeploy to true, and set xmlValidation and xmlNamespaceAware to false.
  8. Save your changes to server.xml.
  9. Restart the Tomcat service. Check the tail of logs/catalina.out and check for any errors that may be in your configuration file.
  10. Go to your Tomcat home page in your web browser and click on several links to verify your instance is running correctly.
  11. Once you are finished with this lab, move your new, custom server.xml to a different filename, then rename server_original.xml to be server.xml again, then restart Tomcat.

Summary: Being able to configure server.xml is a fundamental skill in Tomcat management. Hopefully after completing this lab you are comfortable with modifying the server config file, and also hopefully you made a mistake or two and figured out how to use catalina.out to debug configuration errors - another useful skill!