django configuration
settings.py
DEBUG = FalseALLOWED_HOSTS = ['*']TEMPLATES = [ { ... 'DIRS': [os.path.join(BASE_DIR, 'static')], ... } ]STATIC_URL = '/static/'STATIC_ROOT = os.path.join(BASE_DIR, 'static')MEDIA_URL = '/media/'MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
uwsgi configuration
cd /usr/local/project/mysitetouch uwsgi.logtouch uwsgi.socktouch uwsgi.pidtouch uwsgi.ini
vim uwsgi.ini
[uwsgi]chdir=/usr/local/project/mysite/module=mysite.wsgi:applicationworkers=5pidfile=/usr/local/project/mysite/uwsgi.pidhttp=127.0.0.1:8001static-map=/static=/usr/local/project/mysite/staticuid=rootgid=rootmaster=truevacuum=truethunder-lock=trueenable-threads=trueharakiri=30post-buffering=4096daemonize=/usr/local/project/mysite/uwsgi.logsocket=/usr/local/project/mysite/uwsgi.sock
nginx configuration
vim /etc/nginx/nginx.conf
events { worker_connections 1024;}http { include /etc/nginx/mime.types; default_type application/octet-stream; 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; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf;}vim /etc/nginx/conf.d/mysite.conf
upstream django { server 127.0.0.1:8001;}server { listen 80; server_name server_name; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; charset utf-8; gzip on; gzip_types text/plain application/x-javascript text/css text/javascript application/x-httpd-php application/json text/json image/jpeg image/gif image/png application/octet-stream; error_page 404 /404.html; error_page 500 502 503 504 /50x.html; client_max_body_size 75M; location /media/ { alias /ur/local/project/mysite/media/; } location /static/ { alias /usr/local/project/mysite/static/; } location / { include uwsgi_params; uwsgi_connect_timeout 30; uwsgi_pass unix:/usr/local/project/mysite/uwsgi.sock; }}