After a long time on shared hosting, I'm moving my stuff to a VPS and it has become necessary to learn about Nginx + uWSGI to deploy my apps (python). After spending a couple of weeks learning the basics, I'm in the process of setting up my local machine (ubuntu 11.04) to run my apps on Nginx + uWSGI. I'm using the "Hello world" Ubuntu 10.10 linode guide.
The setup was simple but when I run http://localhost/
or http://127.0.0.1
I get a 502 Bad Gateway everytime. Appreciate pointers on how to get the setup working.
My nginx.conf:
[ I backed up the default nginx conf (which works fine and shows "Welcome to Nginx" when I hit http://localhost/
) and replaced it with this custom nginx conf from the linode guide that links nginx to the uWSGI server. ]
worker_processes 1;
events { worker_connections 1024; }
http {
server {
listen 80;
server_name localhost;
access_log /srv/www/myHostname/logs/access.log;
error_log /srv/www/myHostname/logs/error.log;
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:9001;
}
location /static {
root /srv/www/myHostname/public_html/static/;
index index.html index.htm;
}
}
}
My uWSGI conf is exactly the same as detailed in the linode guide I linked above, with the one change that "duckington.org" in their example replaced with "myHostname" in my setup.
No errors in my nginx error log. Nginx installed at /opt/nginx
and uWSGI is at /opt/uwsgi
as laid out in the guide linked above. I haven't touched any files the guide doesn't talk about.
What I have tried to solve this, so far:
- Starting, stopping and restarting nginx and uWSGI services after modifying their configs.
- Tried the 'debian layout' with
sites-enabled
etc to add my custom vhost listed above while leaving the default nginx.conf untouched (except for the include statement to point to the vhost in sites-enabled). Nginx did not even start and the error log reported a "conflicting server name "localhost" on 0.0.0.0:80, ignored" error. - Read a bunch more guides on Nginx + uWSGI setups without getting any further in solving the issue.