What does this nginx error mean when restarting the server?

Hello I'm running Linode debian 7.0 with nginx 1.2 installed( from debian package repo).

I want to use nginx for my rack app, but i want to learn to server static files first.

When I want to start nginx, I got this error:

Starting nginx: nginx: [emerg] "server" directive is not allowed here in /etc/nginx/sites-enabled/footdotcom:10
nginx: configuration file /etc/nginx/nginx.conf test failed

Here the snippet for my config file in nginx's sites-available/

server {
    listen 80;
    server_name www.foo.com;
    rewrite ^/(.*) http://foo.com/$1 permanent;

}

server {
    listen 80;
    server foo.com;
    access_log /home/mhd/website/foodotcom/access.log;
    error_log /home/mhd/website/foodotcom/error.log;
    location / {
        root  /home/mhd/website/foodotcom/public/;
        index index.html;
    }

}

I followed the config more or less from:

http://socrateos.blogspot.com/2011/08/r … -with.html">http://socrateos.blogspot.com/2011/08/running-rack-app-ramaze-with.html

Any help would be very appreciated

2 Replies

The "/etc/nginx/sites-enabled/footdotcom:10" means that the problem is on line 10 of /etc/nginx/sites-enabled/footdotcom. It's probably the line that says "server" instead of "server_name".

Wow you are right..How could I miss that?? Must be fatigue >_< .Tnx

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct