Setup Virtual Hosting With Tomcat
This tip provides instruction setting up virtual hosting on Tomcat version 6 and above
as Tomcat version 5 structure is a bit different than that of version 6. If you are looking way to integrate
tomcat with Apache2 please follow instruction on
how to integrate tomcat with Apache2.
Step 1: Modify tomcat server.xml file
Add new block of virtual host to server.xml file and save it.
<Host name="www.yourdomainame.com" appBase="yourappsbasedir">
<Alias>yourdomainame</Alias>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="/home/tomcat/logs"
prefix="<yourdomainame>e_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
</Host>
Step 2: create virtual host
- cd /conf/Catalina
- Create a directory and name it exactly as your domain name. For instance, your domain is www.mydomain.com
then the newly created directory name should be www.mydomain.com
mkdir www.mydomain.com
- go to newly created directory: cd www.mydomain.com
- Create a ROOT.xml context file: vi ROOT.xml and add following line to the ROOT.xml context
- <Context path="" docBase="" antiResourceLocking="false" privileged="true" />
- Save the file and restart the tomcat
Step 3: Test your virtual host
open browser and enter
www.domainname.com:8080 (assume your tomcat runs on port 8080).
You should see your website show up properly.
Now you can either change port 8080 to 80 or If you want to integrate tomcat with apache then following instruction on
how to integrate tomcat with Apache2
2244 Old Mill Carrollton, TX 75007 (425) 367-8702
Copyright @ 2008 Tomcat Hosting Services. All
Rights Reserved.