PythonFlup

Welcome to the home of Nginx on Ubuntu - specifically Jaunty Jackalope 9.04. This example uses the excellent Amazon ec2 ami-bf5eb9d6	from Eric Hammond.

First off, you need to install nginx and python-flup:

apt-get install nginx python-flup

You'll note that nginx first of all doesn't start. For now, just start it. I hope that this changes at some point:

service nginx start

You should now see "Welcome to Nginx!" at http://[IP Address]

In /etc/nginx/ you'll see some config files, don't update them. Create a file in /etc/nginx/sites-available/. Any files in there will be included by nginx.conf after they are enabled. This is the content of the file I created, /etc/nginx/sites-available/site

server { listen      80; server_name _;

#charset koi8-r;

#access_log logs/host.access.log  main;

# Get people onto the non-www site if ($host = 'www.example.com' ) { rewrite ^/(.*)$  http://example.com/$1  permanent; }

# project media assuming it's called at media/ # keep in mind that media/ will be maintained as a directory by the root command location ^~ /media/ { root  /site/where/project/is; }

# admin uses admin-media/ # alias works different than root above by dropping admin-media location ^~ /admin-media/ { alias /var/lib/python-support/python2.6/django/contrib/admin/media/; }

location / { # host and port to fastcgi server fastcgi_pass 127.0.0.1:8080; fastcgi_param SERVER_NAME $server_name; fastcgi_param SERVER_PORT $server_port; fastcgi_param SERVER_PROTOCOL $server_protocol; fastcgi_param PATH_INFO $fastcgi_script_name; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param QUERY_STRING $query_string; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_pass_header Authorization; fastcgi_intercept_errors off; }

# todo: setup 404 for the /media directory. # / directory will be handled by django url dispatcher #error_page 404              /404.html; #location = /404.html { #   root   /var/www/nginx-default; #}

# redirect server error pages to the static page /50x.html #       error_page   500 502 503 504  /50x.html; location = /50x.html { root  /var/www/nginx-default; }

}

Now enable the site config:

sudo ln -s /etc/nginx/sites-available/example /etc/nginx/sites-enabled/example

And disable default:

rm /etc/nginx/sites-enabled/default

Now you need to restart nginx and go to the site again

service nginx restart

And start the django fastcgi process:

python ./manage.py runfcgi host=127.0.0.1 port=8080

Restarting python Fastcgi is odd right now. Do this for now:

ps -ef | grep python

Then, grab the parent process id:

kill 1234

Then, restart:

python ./manage.py runfcgi host=127.0.0.1 port=8080

See also: * Django FastCGI init.d script for Linux for information on how to start up your Django FastCGI server(s) on system boot.

References: * Slicehost Nginx enabling/disabling sites