Adding virtual host config, manager for website in Tomcat 6 server.xml

by rajesh 2012-04-18 16:45:35

To add a virtual host entry in tomcat 6, just copy and paste the below code in server.xml above the <Engine> tag and replace the respective values

<Host name="sitename" appBase="/home/username/public_html/webapps">
<Alias>www.sitename</Alias>
<Context path="" reloadable="true" docBase="/home/username/public_html" debug="1"/>
<Context path="/manager" debug="0" privileged="true"
docBase="/usr/local/apache-tomcat-6.0.35/webapps/manager">
</Context>
</Host>

In the above,
replace sitename with the website name to be added for virtual hosting.
replace the path for appBase, docBase values to the proper paths that are needed.

After that, you can restart the server for the changes to take effect.

Tomcat Manager Support:
Even though the above host has manager enabled using the context tag, it wont work until proper user is added in tomcat-users.xml

Add the below tag in tomcat-users.xml above </tomcat-users>

<user username="siteuser" password="password" roles="manager-gui"/>

Give username of the site in username property.
After restarting the server you can access the manager as
http://sitename/manager/html
1544
like
0
dislike
0
mail
flag

You must LOGIN to add comments