How do I use Apache tomcat 7 built in Host Manager gui?
Solution for a fresh install of Tomcat 7 on Ubuntu 12.04.
Edit this file - /etc/tomcat7/tomcat-users.xml
to add this xml section -
<tomcat-users>
<role rolename="admin"/>
<role rolename="admin-gui"/>
<role rolename="manager-gui"/>
<user username="tomcatadmin" password="tomcat2009" roles="admin,admin-gui,manager-gui"/>
</tomcat-users>
restart Tomcat -
service tomcat7 restart
urls to access managers -
- tomcat test page - http://localhost:8080/
- manager webapp - http://localhost:8080/manager/html
- host-manager webapp - http://localhost:8080/host-manager/html
just wanted to put the latest info out there.
Host Manager is a web application inside of Tomcat that creates/removes Virtual Hosts within Tomcat.
A Virtual Host allows you to define multiple hostnames on a single server, so you can use the same server to handles requests to, 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.
Adding a virtual host
Once you have access to the host-manager (see other answers on setting up the permissions, the GUI will let you add a (temporary - see edit at the end of this post) virtual host.
At a minimum you need the Name
and App Base
fields defined. Tomcat will then 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 theName
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.
The checkboxes are as follows:
-
Auto Deploy
: Automatically redeploy applications placed into App Base. Dangerous for Production environments! -
Deploy On Startup
: Automatically boot up applications under App Base when Tomcat starts -
Deploy XML
: Determines whether to parse the application's/META-INF/context.xml
-
Unpack WARs
: Unpack WAR files placed or uploaded to the App Base, as opposed to running them directly from the WAR. -
Tomcat 8
Copy XML
: Copy an application'sMETA-INF/context.xml
to the App Base/XML Base on deployment, and use that exclusively, regardless of whether the application is updated. Irrelevant ifDeploy XML
is false. -
Manager App
: Add the manager application to the Virtual Host (Useful for controlling the applications you might have underneathren.myserver.com
)
Update: After playing around with this same process on Tomcat8, the behaviour I'm seeing is that adding a virtual host via the GUI isn't persistent - it doesn't get written to server.xml
, even on shutdown. Therefore (unless I'm doing something terribly wrong), you can create it in the GUI, but you'll need to edit server.xml
anyway, as per the first link above, to make it stick.
To access "Host Manager" you have to configure "admin-gui" user inside the tomcat-users.xml
Just add the below lines[change username & pwd] :
<role rolename="admin-gui"/>
<user username="admin" password="password" roles="admin-gui"/>
Restart tomcat 7 server and you are done.
I'm not sure about Tomcat 7, but with Tomcat 6... once you start Tomcat:
By going into the bin directory and starting startup.bat
(win) or startup.sh
(Unix/osx) it will spin up a local instance of the server running usually on port 8080 by default. Then by going to http://localhost:8080/ and seeing that it is running, there is a link to the manager. If that page is not there, you can try loading the manager by going directly to manager/html, and that will load the Host Manager gui.
http://localhost:8080/manager/html
Make sure Tomcat is running first and that 8080 is the right port. These are just the defaults that tomcat usually runs with.
To login you need to edit the conf/tomcat-users.xml, and create a Manager GUI role
<role rolename="manager-gui"/>
and add that to a user
<user username="admin" password="password" roles="manager-gui"/>
Then when you go to Manager GUI app at http://localhost:8080/manager/html it will prompt you for a username/password, which you added to that config file.