3. Serving multiple sites from a single installation
Prev | Chapter 3. Basic Concepts | Next

## 3. Serving multiple sites from a single installation

Tomcat and other servlet containers allow to create multiple hosts, and to put multiple contexts within them. Web developers usually need to host more than a single website on the same server, so they end up creating a host for each website and specifying which domains must be served by that host. This is a good setup strategy since it allows to separate sites and to tune their configuration. Nevertheless, this method leads to many installations of MeshCMS that must be maintained separately, which is quite annoying, for example when upgrading.

MeshCMS 3 gives the choice between this approach and a different one: you can install it once and serve all sites from that single context. You will probably configure the host to serve all domains and let MeshCMS map them to different sites. The advantages of this approach are:

- you have to deal with a single installation of the software;

- you will save some server resources;

- you can see the files of all sites from the file manager if you have the needed permissions;

- you can configure the sites and their mappings using the web interface.

The drawbacks are:

- it is more difficult to manage security separately for each site;

- if you use JSP pages in virtual sites, you must keep into account the fact that MeshCMS will map URLs to files differently.

To serve multiple sites, you need to install MeshCMS as usual. Then you can use the Control Panel to create new sites. If the DNS has been configured properly, you can access new sites immediately. Please do so, log into it with your admin user of the main website and check the site configuration to make sure that all options are fine. You may also want to create some users, a welcome page and so on.

### 3.1. Main site and virtual sites

When you install MeshCMS, you have a single site. This is the good old default scenario. You can add a virtually unlimited number of virtual sites on top of it. While virtual sites behave like the main one apparently, there are some differences between. The main difference is the fact that a different file is served when a page of a virtual site is requested. Normally, if you configure a Tomcat host to serve `www.site1.com` and `www.site2.com`, the same file will be served for `http://www.site1.com/index.html` and `http://www.site2.com/index.html`. That file is simply `/index.html`, located in the root context. But if you setup `www.site2.com` as a virtual site on top of `www.site1.com`, a request for `http://www.site2.com/index.html` will lead to `/meshcms/sites/site2.com/index.html`.

Prev | Up | Next
2. External Documents and Tools | Home | Chapter 4. Common Tasks