sudo apt-get install nginx
sudo pip install gunicorn
/home/ubuntu/my_project -- path to the folder containing manage.py
/home/ubuntu/my_project/my_project -- path to the folder containing settings.py
$USER -- your username
sudo nano /etc/init/gunicorn.conf
description "Gunicorn application server handling myproject"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
setuid $USER
setgid www-data
chdir /home/ubuntu/my_project
exec gunicorn -c gunicorn.conf.py --workers 3 --bind unix:/home/ubuntu/my_project/my_project.sock my_project.wsgi:application
sudo nano /home/ubuntu/my_project/gunicorn.conf.py
errorlog = '/home/ubuntu/my_project/logs/gunicorn-error.log'
accesslog = '/home/ubuntu/my_project/logs/gunicorn-access.log'
loglevel = 'debug'
sudo nano /etc/nginx/sites-available/my_project
server {
listen 80;
server_name my.domain.net;
location = /favicon.ico { access_log off; log_not_found off; }
location /static {
alias /home/ubuntu/my_project/static;
}
error_log /home/ubuntu/my_project/logs/error.log info;
access_log /home/ubuntu/my_project/logs/access.log;
location / {
include proxy_params;
proxy_pass http://unix:/home/ubuntu/my_project/my_project.sock;
}
}
sudo ln -s /etc/nginx/sites-available/my_project /etc/nginx/sites-enabled