ubuntu 上使用uwsgi + nginx部署 Django

1.安裝nginx、Django、uwsgi

2.項(xiàng)目目錄下配置uwsgi.ini 使用命令 uwsgi --ini uwsgi.ini 生效uwsgi


[uwsgi]

# Django-related settings

# the base directory (full path)

chdir          = /home/leo/blog

# Django's wsgi filemodule          = blog.wsgi:application

# the virtualenv (full path)

# home            = /path/to/virtualenv# process-related settings

# mastermaster          = true

# maximum number of worker processesprocesses      = 5

# the socket (use the full path to be safe

#socket          = 127.0.0.1:9090

socket          = /home/leo/blog/uwsgi.sock

# ... with appropriate permissions - may be needed

# chmod-socket    = 664

# clear environment on exit

thunder-lock    = truevacuum          = true

daemonize      = bloguwsgi.log

3.配置nginx


server {

        # the port your site will be served on

        listen      80;

# the domain name it will serve forserver_name 192.168.81.132;

# substitute your machine's IP address or FQDN,

#這里是填你的域名或ip,然后在瀏覽器通過這個(gè)訪問charset    utf-8;

# max upload sizeclient_max_body_size 75M; 

# adjust to taste

# Django media

location /media  {

alias /home/leo/blog/media;  # your Django project's media files - amend as required

}

location /static {

alias /home/leo/blog/static; # your Django project's static files - amend as required

}# Finally, send all non-media requests to the Django server.

location / {

uwsgi_pass  unix:///home/leo/blog/uwsgi.sock;

include    uwsgi_params;

# the uwsgi_params file you installed

uwsgi_param UWSGI_CHDIR /home/leo/blog; #你的項(xiàng)目的路徑,最好用完整路徑uwsgi_param

UWSGI_SCRIPT blog.wsgi;

#指向wsgi.py,相對(duì)于項(xiàng)目的根目錄

}

}
?著作權(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)容