Added Server Block for Nginx and now it won't start.

I followed this tutorial. How To Set Up Nginx Server Blocks (Virtual Hosts) on Ubuntu 14.04 LTS

I have an Ubuntu 16.04 server with Nginx. I have had a production website running under Default for almost a year. It is located at /var/www/html. I used the tutorial to add another Server Block to point to /var/www/ I created the new server block in the file /etc/nginx/sites-available/ I linked that file to /etc/nginx/sites-enabled.

I edited the line in nginx.conf as stated in the tutorial.

When I tried to restart Nginx it failed. My production site is now down! So I deleted the link and the new server block file and was able to start Nginx again. Whew!

The new server block file,, contained ONLY what was mentioned in the Example as below:

server { listen 80 default_server; listen [::]:80 default_server ipv6only=on;

root /var/www/;
index.php index index.html index.htm;


location / {
    try_files $uri $uri/ =404;


I then noticed that the original Default server block was Much larger and contained a bunch more lines. Must I include in the new server block file ALL the lines that were in the original Default file but just change the entries at the top??? Note I kept the old Default file because it referred to the production website which is VERY important to keep running.

Thanks for any help.

Submit an answer

This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

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.

Accepted Answer

nginx -t is a helpful command to check your configs before a restart/reload

Well I guess that was the answer. I noticed while looking at the default server block that the php location block was indeed inside the server block of code. I copied the rest of the default server block code in to my new server block and php is now working. A very important point to add to the Digital Ocean tutorial I used to create my new server block.

I had thought that anything in the default server block would be applied to ALL server blocks. Not so!

Ryan Quinn
DigitalOcean Employee
DigitalOcean Employee badge
February 8, 2018

When nginx failed to start it likely included some details on the error it encountered. If they were not then you should be able to find these details in /var/log/nginx/error.log.

By default the config files in /etc/nginx/sites-enabled (and sites-available) should end in .conf - I do not know if this will cause a failure like the one you experienced but it is best practice for nginx configuration files.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel