| << Setup ZoneEdit.com IP Addresses | Home | Conclusion and References >> | |
Hosting Multiple WebsitesNow you are ready to host multiple websites. To do this, just repeat the steps above to register your new domain names and set their nameservers. Be sure to inform your server where to route the incoming requests on the application server. To host your multiple websites there is one file called server.xml that you will be working with a lot. It is located in your Tomcat install directory under the config directory. Right clicking on this file and opening it will open a text editing program such as Notepad. Now do a search for the Host tag <Host> This is usually towards the end of the server.xml file.You will want to create a new set of tags for each website. For example, for this site we would have something like this: <Host name="www.hostmulitplesites.com" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> <Alias>hostmutliplesites.com</Alias> <Alias>www.hostmultiplesites.com</Alias> </Host> This tells your Tomcat server that if a request comes in for hostmulitplesites.com or www.hostmultiplesites.com it should redirect the user to the content located under the webapps directory. If the Host is configured with unpackWARs=true and you put a war file in the appBase directory, the war file will be unpacked automatically into a directory with the same name as the war file. If the Host is configured with autoDeploy=true, the Context path must match the directory name or war file name without the ".war" extension. This means that once the war is unpacked it will immediately become live on the server. The Alias tag is where you define all of the alternative names for this website. If you had a second website named: www.secondsite.com you would want to specify a different location for the application so that the content does not overlap.It could be something like this: <Host name="www.secondsite.com" appBase="C:\TomCat\SecondSite" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> <Alias>secondsite.com</Alias> <Alias>www.secondsite.com</Alias> <Context path="" docBase="C:\TomCat\SecondSite" debug="0" reloadable="false"/> <Context path="/SecondSite" docBase="C:\TomCat\SecondSite" debug="0" reloadable="false"/> </Host> This means that you’d put all of the files for this site (the war, html, jsp, Java files, images, everything) under the SecondSite directory. It should look something like this:
Save your server.xml file and restart Tomcat. Now when you go to www.secondsite.com it’ll take you to the content you were hoping it would go to. And when you go to www.hostmultiplesites.com it’ll go to the content under the webapps/ROOT directory. Pretty cool. |
|
| << Setup ZoneEdit.com IP Addresses | Home | Conclusion and References >> | |