Question

I'm following this deployment tutorial for running Flask with UWSGI and Nginx. At slide number 11 the contents of an nginx config file are given:

server {
    listen 8080;
    server_name myapp;

    root /var/www/myapp;
    try_files $uri @uwsgi;
    location @uwsgi {
        include uwsgi_params;
        uwsgi_pass unix:/tmp/myapp.sock;
    }
}

and from the next slide (number 12) I understand that those contents should go into the file /etc/nginx/sites-available/www. So I did as I understood, but upon restarting nginx (sudo service nginx restart), I get an error saying nginx: configuration file /etc/nginx/nginx.conf test failed.

The strange thing is that I never touched that nginx.conf file (I copied its contents here on pastebin), bit it still causes an error.

Does anybody know what I'm doing wrong, and more importantly, how I can solve this? All tips are welcome!

[EDIT] After the tips from @MohammadAbuShady , I fixed the space in the @ and uwsgi, but I still get the same error. Running the suggested sudo nginx -t gives me the following information:

nginx: [emerg] unknown directive "uwsgi_param" in /etc/nginx/uwsgi_params:1
nginx: configuration file /etc/nginx/nginx.conf test failed

Does this give any new information?

Was it helpful?

Solution

Your problem is probably the space between @ and uwsgi , named locations should be written like this

location @uwsgi {
  #config
}

The error was reported inside nginx.conf because that is the config file that includes the other files inside sites-enabled, check line 72 in your pastebin

include /etc/nginx/sites-enabled/*;

Also don't use sudo service nginx restart because by doing the shutdown is successful and the start up again fails, so you end up with a dead server, instead use sudo service nginx reload this way you wouldn't loose your uptime if your config is wrong.

To check where the config error is you can always run sudo nginx -t to test the config files.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top