美文网首页
ubuntu 上使用uwsgi + nginx部署 Djang

ubuntu 上使用uwsgi + nginx部署 Djang

作者: axjldt | 来源:发表于2017-12-23 17:27 被阅读0次

1.安装nginx、Django、uwsgi

2.项目目录下配置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,然后在浏览器通过这个访问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; #你的项目的路径,最好用完整路径uwsgi_param

UWSGI_SCRIPT blog.wsgi;

#指向wsgi.py,相对于项目的根目录

}

}

相关文章

网友评论

      本文标题: ubuntu 上使用uwsgi + nginx部署 Djang

      本文链接:https://www.haomeiwen.com/subject/rcuqgxtx.html