How to Create VirtualHost in Tomcat 8

Hi folks,

Today I will discuss how to create a VirtualHost on Tomcat 8. For those who don’t know, Tomcat is a very popular open-source web server for hosting Java web applicationsm. Tomcat implements a bunch of Java EE specifications like Java Servlet, JavaServer Pages (JSP), Websocket and Java EL [1].

Let’s assume you installed Tomcat 8 in /usr/local/apache-tomcat-8.0.30. you want to add a virtual host Assume the project folder is at /usr/local/apache-tomcat-8.0.30/webapps/myapp

Open the file /usr/local/apache-tomcat-8.0.30/conf/server.xml
Then add the following lines:

 <Host name="" appBase="webapps" unpackWARs="true" autoDeploy="true">
 <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
 prefix="sweetapp_access_log" suffix=".txt"
 pattern="%h %l %u %t "%r" %s %b" />
 <Context path="" docBase="/usr/local/apache-tomcat-8.0.30/webapps/myapp"
 debug="0" reloadable="true"/>

Save and close the file.

Then restart tomcat using the commands:



Apache Tomcat – Wikipedia, the free encyclopedia.

2 thoughts on “How to Create VirtualHost in Tomcat 8”

  1. Sorry this is not working!
    I tried hosting it but the moment I start tomcat with startup.cmd
    it closes the moment it is opened.

    1. The instructions I put here were tried on OS X. It seems you are using Windows. Try checking your server log file to determine what is causing the error.

Leave a Reply

Your email address will not be published. Required fields are marked *