Tomcat virtual hosts

From Oxxus Wiki

Jump to: navigation, search

You can configure virtual hosts to handle either separate domains or sub domains that are available on your VPS.

Adding new virtual host

You will need to edit server.xml file add/modify the Host container definitions.

<Host name="www.mycompany.com" ...>
  ...
  <Alias>mycompany.com</Alias>
  ...

  <Context> ... </Context>
</Host>

Important options for Host container are:

appBase
The Application Base directory for this virtual host. This is the pathname of a directory that may contain web applications to be deployed on this virtual host. You may specify an absolute pathname for this directory, or a pathname that is relative to the $CATALINA_BASE directory.

The Context element represents a web application, which is run within a particular virtual host.

Important options for Context container are:

docBase
The Document Base (also known as the Context Root) directory for this web application, or the pathname to the web application archive file (if this web application is being executed directly from the WAR file). You may specify an absolute pathname for this directory or WAR file, or a pathname that is relative to the appBase directory of the owning Host.

You can have as many host containers a you want.

Default host used is defined within <Engine> tag.

<Engine name="Catalina" defaultHost="localhost">

Make sure to restart your Tomcat server after you make any changes.

Following the output in the Tomcat log file can give you information of any errors that might have occurred during the start up caused by incorrect or missing configuration.

cd /var/tomcatX/logs/
tail -f catalina.out

Notes

If you've registered new domain by yourself, have in mind that this new domain needs to be added to our name servers and pointed at your VPS before you can use it. Please submit a support request and we'll do the necessary steps to make your domain available for use on the VPS. View all available Tomcat hosting solutions

Contact About Us Support Network Servers Java Hosting Oxxus.net Order Now! Dedicated Servers VPS Hosting Tomcat Hosting Java Hosting Money Back Guarantee Privacy Policy Oxxus.net Terms of 
Service Contact About Us Servers Networks Support Domain Names SSL Certificates Java Wiki Tutorials E-learning 
Platforms