uwsgi与nginx安装过程:略
django工程结构:
demosite_uwsgi.ini内容:
[uwsgi]
socket= :8080
chdir=/root/test/demosite
module=demosite.wsgi
master=true
processes=4
vacuum=true
nginx.conf
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
###以下为新增内容
server {
listen 8090;
server_name localhost;
charset UTF-8;
access_log /var/log/nginx/demosite_access.log;
error_log /var/log/nginx/demosite_error.log;
client_max_body_size 75M;
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:8080;
uwsgi_read_timeout 2;
}
#location / {
# root html;
# index index.html index.htm;
#}
#新添加的location
#location / {
#将所有的参数转到uwsgi下
# include uwsgi_params;
#uwsgi的ip与端口
# uwsgi_pass 127.0.0.1:8080;
#}
location /static/ {
expires 30d;
autoindex on;
add_header Cache-Control private;
alias /root/test/demosite/static/;
}
#error_page 404 /404.html;
###以上为新增内容
}
}
启动uwsgi:
uwsgi --ini demosite_uwsgi.ini
启动nginx:
service nginx restart