Adding subdomain on NGINX (CentOS)

  • Posted January 28, 2014

Hey guys,

I had a working nginx config for my domain, but now I want to add a subdomain to the config. I have following virtual.conf in my /etc/nginx/conf.d folder and it looks like this: Basically I just copied the serverblock that was working and changed the server_name and paths.

My fist server block is still working, but the subdomain isn’t. Any idea what the problem is?


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.

It’s working now, thanks a lot for the help!

Remove your domain from DigitalOcean’s DNS manager and re-add it as instead of, but I see doesn’t work, which it did before … maybe the problem is somewhere there?

What is the domain name?

Sorry guys, but it’s still not working I set it up like this ( and waited until the zone file was refreshed and restarted nginx, but I’m not seeing the index.php that’s in the folder. I get “Oop Chrome couldn’t find …” <br>

One of them, yes.

Oh no I didn’t do that, thanks for the info! <br>The example is more complex than what I want though, not sure if I did it correctly. <br>I just need to add a CNAME record “subdomain” and “” right?

Did you add A record and Cname to your DNS at DO?? <br> <br>I guess this is what you are missing, check here: <br> <br>

Yes I ran: sudo service nginx restart a couple of times.

Have you restarted nginx?