0

I'm trying to have multiple sites on the same server. I have a DigitalOcean VPS with Debian and Nginx. Whatever I go to site1.com, site2.com or site3.com, the site shows the site1.com content. Also, when I type www.site.com, www.site2.com or www.site3.com Chrome shows "This webpage is not available"

On .../sites-available/ and .../sites-enabled/ I have the site1.com, site2.com and site3.com files with the following content. This is from site1.com:

server {
listen 80;
server_name site1.com  www.site1.com;
access_log /opt/www/site1.com/access.log;

root /opt/www/site1.com; }

This is from site2.com:

server {
listen 80;
server_name site2.com  www.site2.com;
access_log /opt/www/site2.com/access.log;

root /opt/www/site2.com; }

And from site3.com:

server {
listen 80;
server_name site3.com  www.site3.com;
access_log /opt/www/site3.com/access.log;

root /opt/www/site3.com; }

What am I doing wrong? As you may predict, yes, this is my first time setting up a Nginx server.

Thanks for your help!

3
  • Did you restart nginx? Did you check your DNS? Those aren't your real domain names... Oct 18, 2014 at 2:24
  • Yes, I restarted Nginx and checked my DNS but still doesn't work. I used those names for example :)
    – Samuel
    Oct 18, 2014 at 2:44
  • do all the 3 sites DNS name point to the IP addresses configured on DO VPS ?
    – drookie
    Oct 18, 2014 at 4:51

1 Answer 1

1

You need to tell Nginx which documents to serve from the root domain directories if the directory is requested by the client.

Try adding:

    index index.html index.htm;

below the root declaration. This will tell nginx what file types to serve from the directory

You have to reload/restart nginx after any configuration changes.

For reference:

http://nginx.org/en/docs/http/ngx_http_index_module.html

4
  • I added that line below the root declaration and now it works! Thank you very much! Problem solved.
    – Samuel
    Oct 18, 2014 at 3:15
  • Dont forget to accept the answer if it helped you solve your problem.
    – Robert hue
    Oct 18, 2014 at 3:42
  • You have to restart nginx after any configuration changes.. Just to clear things out - you may reload nginx as well.
    – Glueon
    Oct 18, 2014 at 9:44
  • @Glueon Yes thanks Glueon I have updated the answer with clarification.
    – devatnull
    Oct 18, 2014 at 9:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .