阿里云部署Django(Ubuntu+uWSGI+Nginx)

1. 安裝uWSGI

`pip install uwsgi`

阿里云ubuntu自帶python2.7,在安裝WSGI之前需要安裝新版本的python,如python3.6,同時(shí)也要將Django項(xiàng)目中需要引用的包安裝完成。

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.啟動(dòng)

啟動(dòng)nginx:service nginx restart
啟動(dòng)uwsgi:uwsgi /etc/uwsgi/sites/project.ini

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容