nginx, python3, uwsgi, django stack on Arch Linux (Raspberry Pi2)

1. Install necessary packags from repo.
sudo pacman -S python sqlite nginx python-pip python-django

2. Install uwsgi.
sudo pip install uwsgi

3. Set up uwsgi emperor
mkdir /etc/uwsgi
mkdir /etc/uwsgi/vassals

vim /etc/uwsgi/emperor.ini
[uwsgi]
emperor = /etc/uwsgi/vassals
#uid = http
#gid = http

vim /etc/systemd/system/emperor.uwsgi.service
[Unit]
Description=uWSGI Emperor
After=syslog.target

[Service]
ExecStart=/usr/bin/uwsgi –ini /etc/uwsgi/emperor.ini
ExecReload=/bin/kill -HUP $MAINPID
ExecStop=/bin/kill -INT $MAINPID
Restart=always
Type=notify
StandardError=syslog
NotifyAccess=all
KillSignal=SIGQUIT

[Install]
WantedBy=multi-user.target

4. Create first site.
django-admin.py startproject mysite

5. Place configuration files in the project directory
cd mysite
cp /etc/nginx/uwsgi_params ./

vim mysite_nginx.conf
upstream django {
#server unix:///path/mysite.sock; # for using unix socket
server 127.0.0.1:8001;
}

server {
listen 80;
server_name 10.0.0.5;
charset utf-8;

location / {
uwsgi_pass django;
include /path/uwsgi_params;
}
}

vim /etc/nginx/nginx.conf and add below to http directive
include /etc/nginx/sites-enabled/*;

mkdir /etc/nginx/sites-enabled/
sudo ln -s /path/mysite/mysite_nginx.conf /etc/nginx/sites-enabled/

vim mysite_uwsgi.ini
[uwsgi]

chdir = /home/users/www/mysite/
module = mysite.wsgi
master = true
processes = 4
socket = 127.0.0.1:8001

sudo ln -s /path/mysite_uwsgi.ini /etc/uwsgi/vassals/

5. start the services
systemctl start emperor.uwsgi
systemctl start nginx

6. django
cd mypage
python manage.py migrate
python manage.py createsuperuser

Access http://127.0.0.1/admin

Advertisements
Leave a comment

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

%d bloggers like this: