-
Notifications
You must be signed in to change notification settings - Fork 9
backend deploy
Zhe Xiao edited this page Aug 8, 2017
·
1 revision
# must pip3 if you have Python 2 & 3 in the machine
> sudo pip3 install uwsgi
# test uwsgi
> uwsgi --http :8000 --home=/vagrant/mnet/env --module mnet.wsgi
> sudo mkdir /var/log/uwsgi
> sudo chmod -R 777 /var/log/uwsgi
uwsgi.ini
[uwsgi]
chdir=/vagrant/mnet
home=/vagrant/mnet/env
module=mnet.wsgi:application
socket=/tmp/mnet.sock
chmod-socket = 666
master=True
processes = 5
max-requests=5000
# clear environment on exit
vacuum=True
pidfile=/tmp/mnet-master.pid
daemonize=/var/log/uwsgi/mnet.log
> uwsgi --ini uwsgi.ini
kill process
> killall -s INT /usr/local/bin/uwsgi
> sudo apt-get install nginx
> sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/uwsgi
> sudo ln -s /etc/nginx/sites-available/uwsgi /etc/nginx/sites-enabled/
> sudo vim /etc/nginx/snippets/uwsgi_params
======
uwsgi_param QUERY_STRING $query_string;
uwsgi_param REQUEST_METHOD $request_method;
uwsgi_param CONTENT_TYPE $content_type;
uwsgi_param CONTENT_LENGTH $content_length;
uwsgi_param REQUEST_URI $request_uri;
uwsgi_param PATH_INFO $document_uri;
uwsgi_param DOCUMENT_ROOT $document_root;
uwsgi_param SERVER_PROTOCOL $server_protocol;
uwsgi_param REQUEST_SCHEME $scheme;
uwsgi_param HTTPS $https if_not_empty;
uwsgi_param REMOTE_ADDR $remote_addr;
uwsgi_param REMOTE_PORT $remote_port;
uwsgi_param SERVER_PORT $server_port;
uwsgi_param SERVER_NAME $server_name;
======
# the upstream component nginx needs to connect to
upstream django {
server unix:///tmp/mnet.sock;
}
server {
# the port your site will be served on
listen 8000;
server_name 127.0.0.1;
charset utf-8;
# max upload size
client_max_body_size 10M;
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass django;
include /etc/nginx/snippets/uwsgi_params;
}
}
> sudo service nginx restart