Question

Cant setup subdomain (address in use)?

  • Posted April 26, 2014

I am not seting up my nginx virtial host blocks up properly, but I don’t get how to serve a subdomain on port:80 and the main domain on port:80?

I tried creating multiple virtual hosts, but I was getting an error with server_names_hash_bucket_size 64; I had to uncomment that out inside nginx.conf to get it work and at this point I already went ahead an merged both virtual hosts into the default file.

server { listen 80;

root /var/www/example.com/public_html/public;
index index.html index.htm;

# Make site accessible from http://example.com
server_name example.com;

}

server { listen 80;

root /var/www/demo.example.com/public_html;
index index.html index.htm;

# Make site accessible from http://demo.example.com
server_name demo.example.com;

}

Obviously I am pointing both to port:80 but I am not sure how to configure it so they both work on port:80.

I followed https://www.digitalocean.com/community/articles/how-to-set-up-nginx-virtual-hosts-server-blocks-on-ubuntu-12-04-lts--3

But I am missing something.

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

If for some reason you want to keep Apache installed, but set it so that it doesn’t automatically start on boot, you can run: <br> <br><pre> <br>sudo update-rc.d apache2 disable <br></pre>

Oh it looks like when you restart your droplet apache2 starts on its own… I stoped apache2 as a service, and restarted nginx , it appears to be working. <br> <br>I also uncommented port:80 on the second virtual host for my subdomain, so it’s working not. I need to uninstall apache…