ubuntu, django, gunicorn, nginx

sudo apt-get install nginx python-pip libpq-dev supervisor

 

export LC_ALL=C

 

sudo pip install django gunicorn psycopg2

Open:

sudo nano /etc/nginx/sites-available/default

Paste:

server {
listen 80;
server_name 192.168.23.109;
access_log /var/log/nginx/access.log;

location /static/ {
alias /home/django/web/static;
}

location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}

 

For test guincorn:

gunicorn sg_web.wsgi:application

for re-test:

killall gunicorn

 

For autostart after reboot, open:

nano /etc/supervisor/conf.d/sg_web.conf

Paste:

[program:sg_web]

command=gunicorn sg_web.wsgi:application -c /home/django/sg_web/sg_web/gunicorn.conf.py

directory=/home/djangp/sg_web

user=nobody

autorestart=true

redirect_stderr=true

 

sudo systemctl enable supervisor

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s