I've read some other answers to the almost exactly same question, but they don't seem to be addressing my query (some of them due to diff environ etc).
I'm setting up a new ubuntu server on DO. On it I created a file /etc/nginx/sites-available/3.conf. In this file only this code is there (I've tried the remaining lines of code also, but then also same result).
server {
listen 80
listen [::]:80;
server_name 3.hotelbobbygg.xyz;
}
And yet when I test it like this
root@2:~# nginx -t -c /etc/nginx/sites-available/3.conf
It gives the following error:
nginx: [emerg] "server" directive is not allowed here in /etc/nginx/sites-available/3.conf:1
nginx: configuration file /etc/nginx/sites-available/3.conf test failed
And if I delete all the contents in this file, even then it gives this error:
syntax is ok
nginx: [emerg] no "events" section in configuration
nginx: configuration file /etc/nginx/sites-available/3.conf test failed
And if I give this: nginx -t
then it tests ok
Its just a new droplet, and besides updating the os and creating a sub folder under /var/www/
I haven't touched any other file.
Pls answer in the words for a guy who is new to servers and is trying to learn the basic functionality (I've setup a discourse site successfully on ubuntu and now am wanting to setup another website on the same droplet/server).