Я создал свой сайт Django на EC2, используя Nginx и Gunicorn, и я следовал этим шагам
easy_install gunicorn
apt-get install nginx
nano /etc/init/site1.conf и добавлено
description "site1 web server"
start on runlevel [2345]
stop on runlevel [06]
respawn
respawn limit 10 5
exec /home/scripts/gunicorn_runserver.sh
и в gunicorn_runserver.sh
#!/bin/bash
set -e
LOGFILE=/var/log/nginx/site1.log
NUM_WORKERS=10
# user/group to run as
USER=www-data
GROUP=adm
cd /home/projects/project_name/
# source ../../bin/activate
exec gunicorn_django -w $NUM_WORKERS \
--user=$USER --group=$GROUP --log-level=error \
--log-file=$LOGFILE 2>>$LOGFILE
и в Nginx conf
upstream app_server_site1 {
server localhost:8000 fail_timeout=0;
}
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
if (!-f $request_filename) {
proxy_pass http://app_server_site1;
break;
}
}
наконец
/etc/init.d/nginx restart
service site1 start
Подробное описание о Nginx + Django + Gunicorn здесь и Nginx + Django + Fcgi здесь