Report this

What is the reason for this report?

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

Posted on February 8, 2018

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/causeaction.com/html. I created the new server block in the file /etc/nginx/sites-available/causeaction.com. 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, causeaction.com, contained ONLY what was mentioned in the Example as below:

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

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

server_name causeaction.com www.causeaction.com;

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.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.