How to host multiple websites in one server


I want to replicate our staging environment.
We have several related sites all hosted on a single box.
Each site is in a different folder. and index.php page and dependancies etc.

Since my workspace has its own subdomain:URL, can I configure things so that I can call each site via a sub/subdomain?



Host from which request comes can be found from request headers. Try the following node script to check that:

require("http").createServer(function(req, res) {
    res.writeHead(200, {"Content-Type": "text/plain"});
    delete req.headers.cookie;
    res._hasBody && res.write(JSON.stringify({
        headers: req.headers,
        url: req.url
    }, null, 4));
}).listen(process.env.PORT || 8080, process.env.IP || "");

console.log("try opening\n"
    + "    http://test1." + process.env.C9_HOSTNAME + " or\n"
    + "    http://test2." + process.env.C9_HOSTNAME + "\n"

You can configure apache to forward to correct folder based on subdomain from which request comes

Using HOST header (or virtual hosts) to render different content from same app?
Too many redirects with multiple ServerAliases
Test wildcard domains

Can you please reply with some sample rules for setting up apache to forward to folder based on subdomain?


the rules are exactly the same as for any other ubuntu installation.
e.g. see