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.
-
Start by creating a backup copy of your configuration file by renaming your current conf/server.xml to server_original.xml.
-
Using a text editor of your choosing, create a new conf/server.xml file.
-
Add the <Server> element with a shutdown port of 8005 and a shutdown command of “goodbye”.
-
Add a <Service> named “MyService”.
-
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.
-
Also within the Service, add an Engine named “MyEngine” whose defaultHost is “localhost”.
-
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.
-
Save your changes to server.xml.
-
Restart the Tomcat service. Check the tail of logs/catalina.out and check for any errors that may be in your configuration file.
-
Go to your Tomcat home page in your web browser and click on several links to verify your instance is running correctly.
-
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!