1. 安裝uWSGI
`pip install uwsgi`
阿里云ubuntu自帶python2.7神得,在安裝WSGI之前需要安裝新版本的python悼吱,如python3.6乐导,同時也要將Django項目中需要引用的包安裝完成肯骇。
2.uWSGI配置文件
在uwsgi的文件夾中建立配置文件:
cd /etc/uwsgi/sites
如果沒有sites文件夾圃泡,可以先創(chuàng)建該文件夾 mkdir 文件名
碟案。
然后創(chuàng)建并編輯文件
vim project.ini
[uwsgi]
http = :8000
# the base directory (full path)
chdir = /root/path/to/project
# Django s wsgi file
module = project.wsgi
master = true
# maximum number of worker processes
processes = 4
# ... with appropriate permissions - may be needed
vacuum = true
3.Nginx的安裝和配置
安裝
apt-get install nginx
創(chuàng)建配置文件
vim /etc/nginx/sites-available/project
server {
listen 8001;
server_name ip; #服務(wù)器公網(wǎng)ip
access_log /var/log/nginx/myweb_access.log;
error_log /var/log/nginx/myweb_error.log;
location /static/ {
root root/path;#靜態(tài)文件地址
}
client_max_body_size 75M;
location / {
include uwsgi_params;
uwsgi_pass unix:/path/project.sock;
}
}
4.啟動
啟動nginx:service nginx restart
啟動uwsgi:uwsgi /etc/uwsgi/sites/project.ini