uuntuではuwsgi+nginxを使ってDjangoを展開しています.
1680 ワード
1.nginx、Django、uwsgiをインストールする
2.プロジェクトディレクトリにuwsgi.iniを配置し、コマンドuwsgi--ini uwsgi.iniを使用して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.inxの設定
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,
}
}