ini 我用于服务Django项目的默认Nginx配置。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ini 我用于服务Django项目的默认Nginx配置。相关的知识,希望对你有一定的参考价值。

# file: /etc/nginx/sites-available/example.com
# nginx configuration for example.com

server {
	listen 80;
	server_name example.com;
	access_log /srv/www/example.com/logs/access.log;
	error_log /srv/www/example.com/logs/error.log;
	
	# pass root to django
	location / {
		include uwsgi_params;
		uwsgi_pass unix://tmp/example.sock;
		# disallow .py, .wsgi, and .conf
	}
	
	# serve django static files
	location /static {
		root /srv/www/example.com/site;
	}
	
	# alias robots.txt to static
	location /robots.txt {
		alias /srv/www/example.com/site/static/robots.txt;
	}
	
	# alias favicon.* to static
	location ~ ^/favicon.(\w*)$ {
		alias /srv/www/example.com/site/static/favicon.$1;
	}
	
	# alias stylesheets to static
	location ~ ^/([^/]*\.css)$ {
		alias /srv/www/example.com/site/static/css/$1;
	}
	
	# serve django uploaded media
	location /media {
		root /srv/www/example.com/site;
	}
}

以上是关于ini 我用于服务Django项目的默认Nginx配置。的主要内容,如果未能解决你的问题,请参考以下文章

django 项目生产环境部署

Django部署uwsgi+nginx

ini nginx默认站点服务器

部署Django项目Nginx + uwsgi

Nginx之美多商城前台部署

Django项目部署(nginx+uWSGI+django+virtualenv+supervisor发布web服务器 )