How to use Tomcat 7 Host Manager

Tomcat Host Manager is a web application inside of Tomcat that manages Virtual Hosts within the Tomcat application server.

A Virtual Host allows you to define multiple hostnames on a single server, so you can use the same server to handles requests to different subdomains, for example, ren.myserver.com and stimpy.myserver.com.

Unfortunately documentation on the GUI side of the Host Manager doesn't appear to exist, but documentation on configuring the virtual hosts manually in context.xml is here:

http://tomcat.apache.org/tomcat-7.0-doc/virtual-hosting-howto.html.

The full explanation of the Host parameters you can find here:

http://tomcat.apache.org/tomcat-7.0-doc/config/host.html.

Accessing the Virtual Host Manager

To access the virtual host manager, you need to have appropriate permissions set up in your tomcat-users.xml - at the very least the manager-gui role (see the official documentation here for full information). It should look something like this:

<role rolename="manager-gui"/>
  <user username="tomcat-admin" password="change-me!"
roles="manager-gui"/>
</role>

Once you have access, you can access the host-manager application at http://localhost:8080/host-manager.

Adding a new virtual host

The Add Virtual Host panel looks like this:

Tomcat Virtual Host Manager

At a minimum you need the Name and App Base fields defined. From those, Tomcat will create the following directories:

{CATALINA_HOME}\conf\Catalina\{Name} 
{CATALINA_HOME}\{App Base}

App Base will be where web applications will be deployed to the virtual host. Can be relative or absolute.

Name is usually the fully-qualified domain name (e.g. ren.myserver.com)

Alias can be used to extend the Name also where two addresses should resolve to the same host (e.g. www.ren.myserver.com). Note that this needs to be reflected in DNS records.

I'll let you look up the other manual parameters, but I find the most useful ones are:

Unpack WARs: Unpack WAR files placed or uploaded to the App Base, as opposed to running them directly from the WAR.

Auto Deploy: Automatically redeploy applications placed into App Base. Careful - this is potentially dangerous for Production environments!

Deploy On Startup: Automatically boot up applications under App Base when Tomcat starts

Copy XML: Copy an application's META-INF/context.xml to the App Base/XML Base on deployment, and use that exclusively, regardless of whether the application is updated. Irrelevant if Deploy XML is false (Tomcat 8 only).

Deploy XML: Determines whether to parse the application's /META-INF/context.xml

Manager App: Add the manager application to the Virtual Host (Useful for controlling the applications you might have underneath ren.myserver.com). You would then access this at http://{Name}/manager

Once you hit Add, Tomcat will create the directories above and move in the tomcat-manager app config under {CATALINA_HOME}\conf\Catalina\{Name}. You should be able to hit that straight away!

Now, a warning..

You need to add your virtual-host entry to Tomcat's server.xml for it to persist after a restart! (See the documentation link at the start of the article for how to do this)

For who-knows-what reason, the virtual-host entry you add via the GUI isn't written to disk. So, you may ask yourself, why don't I just add the entry into server.xml instead of trying to use the GUI? Good question..

Originally posted by myself as an answer on stackoverflow.com.