| # The Apache Tomcat 5.5 Servlet/JSP Container |

Links Docs Home FAQ User Guide 1) Introduction 2) Setup 3) First webapp 4) Deployer 5) Manager 6) Realms and AAA 7) Security Manager 8) JNDI Resources 9) JDBC DataSources 10) Classloading 11) JSPs 12) SSL 13) SSI 14) CGI 15) Proxy Support 16) MBean Descriptor 17) Default Servlet 18) Clustering 19) Load Balancer 20) Connectors 21) Monitoring and Management 22) Logging 23) APR 24) Virtual Hosting Reference Release Notes Apache Tomcat Configuration JK 1.2 Documentation Servlet API Javadocs JSP API Javadocs Apache Tomcat Development Building Changelog Status Developers Functional Specs. Apache Tomcat Javadocs Apache Jasper Javadocs Architecture |
# The Apache Tomcat 5.5 Servlet/JSP Container ## Virtual Hosting and Tomcat | print-friendly version
Assumptions
For the sake of this how-to, assume you have a development host with two host names, `ren` and `stimpy`. Let's also assume one instance of Tomcat running, so `$CATALINA_HOME` refers to wherever it's installed, perhaps `/usr/local/tomcat`. Also, this how-to uses Unix-style path separators and commands; if you're on Windows modify accordingly.
server.xml
> At the simplest, edit the Engine portion of your `server.xml` file to look like this:
>     <Engine name="Catalina" defaultHost="ren">
>         <Host name="ren"    appBase="webapps/ren"/>
>         <Host name="stimpy" appBase="webapps/stimpy"/>
>     </Engine>
Consult the configuration documentation for other attributes of the Engine and Hostelements.
Webapps Directory
> Create directories for each of the virtual hosts:
>     mkdir $CATALINA_HOME/webapps/ren
>     mkdir $CATALINA_HOME/webapps/stimpy
Configuring Your Contexts
> Approach #1
> Within your Context, create a `META-INF` directory and then place your Context definition in it in a file named `context.xml`. i.e. `$CATALINA_HOME/webapps/ren/ROOT/META-INF/context.xml` This makes deployment easier, particularly if you're distributing a WAR file.
> Approach #2
> > Create a structure under `$CATALINA_HOME/conf/Catalina` corresponding to your virtual hosts, e.g.:
> >     mkdir $CATALINA_HOME/conf/Catalina/ren
> >     mkdir $CATALINA_HOME/conf/Catalina/stimpy
> > Note that the ending directory name "Catalina" represents the `name` attribute of the Engine element as shown above. Now, for your default webapps, add:
> >     $CATALINA_HOME/conf/Catalina/ren/ROOT.xml
> >     $CATALINA_HOME/conf/Catalina/stimpy/ROOT.xml
> > If you want to use the Tomcat manager webapp for each host, you'll also need to add it here:
> >     cd $CATALINA_HOME/conf/Catalina
> >     cp localhost/manager.xml ren/
> >     cp localhost/manager.xml stimpy/
> Further Information
> Consult the configuration documentation for other attributes of the Context element.
Copyright © 1999-2006, Apache Software Foundation