Server Guru

Just another Tech Blog

LinuxTomcat

Create Virtual Host in Apache Tomcat 7 and 8

 

In order to create virtual host in Tomcat please follow the steps given below.

 

Step 1 : Create your document root under the $CATALINA_HOME

 

mkdir /opt/tomcat/apache-tomcat-8.5.24/webapps/MySite

 

Step 2 : Edit the “$CATALINA_HOME/conf/server.xml” file with the following syntax.

 

<Host name=”mytomcatsite.com” appBase=”webapps” unpackWARs=”true” autoDeploy=”true”>
<Alias>www.mytomcatsite.com</Alias>
<Valve className=”org.apache.catalina.valves.AccessLogValve” directory=”logs” prefix=”mysite_access_log” suffix=”.txt” pattern=”%h %l %u %t &quot;%r&quot; %s %b” />
<Context path=”” docBase=”/opt/tomcat/apache-tomcat-8.5.24/webapps/MySite” reloadable=”true”/>
</Host>
</Engine>
</Service>
</Server>

Step 3 : Restart Tomcat service

 

Step 4 : Upload your jsp files to the “/opt/tomcat/apache-tomcat-8.5.24/webapps/MySite”.  

That’s all !!

Leave a Reply