Search code examples
hostingdnsvps

Hosting two domains using only one VPS?


Is it possible? Someone told me it is but I'm not sure.

If its possible, how should I do it? I have one /www folder where my website lies. How can I configure 2 different sites?


Solution

  • The procedure is:

    1. Point both domains to the ip of the VPS.

    2. Configure the webserver you have installed on your VPS to answer to those two domains.

    In the case of Nginx with Passenger, it is a matter of adding entries to you nginx.conf file. Like this:

    server {
          listen 80;
          server_name domain1;
          root /path/to/your/project;
          passenger_enabled on;
       } 
    server {
          listen 80;
          server_name domain2;
          root /path/to/your/project;
          passenger_enabled on;
       }
    

    Check your webserver documentation to do a similar thing.