How to host multiple websites in one server


#1

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?

C


#2

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({
        host: req.headers.host,
        headers: req.headers,
        url: req.url
    }, null, 4));
    res.end();
}).listen(process.env.PORT || 8080, process.env.IP || "0.0.0.0");


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
#3

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


#4

the rules are exactly the same as for any other ubuntu installation.
e.g. see http://stackoverflow.com/a/36459496/1743328