Nginx+uwsgi+Django

1、安装uwsgi

2、安装nginx

3、配置nginx:

cd /etc/nginx/conf.d/
配置xxx.conf
server{ 
		listen 80;   # 监听端口
		server_name localhost ; # 域名
		access_log /var/log/nginx/access.log main; 	# Nginx日志配置
		charset utf-8; 		# Nginx编码
		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; 	# 错误页面

		# 指定项目路径uwsgi
		location / { 
				include uwsgi_params; 		# (需要提前准备好文件)导入一个Nginx模块他是用来和uWSGI进行通讯的
				uwsgi_connect_timeout 30; 	# 设置连接uWSGI超时时间
				uwsgi_pass unix:/opt/proj/script/uwsgi.sock; 	# 方式1,对应uwsgi.ini中的socket
				uwsgi_pass 127.0.0.1:9090			# 方式2,对应uwsgi.ini中的socket
		}

		# 指定静态文件路径(如果还有media等配置类似)
		location /static/ {
				alias /opt/proj/teacher/static/;
				index index.html index.htm;
		}
}

  

4、配置uwsgi

配置uwsgi.ini

[uwsgi]
socket=/opt/proj/script/uwsgi.sock  # 方式1,对应nginx配置中的uwsgi_pass
socket=127.0.0.1:9090		    # 方式2,对应nginx配置中的
uwsgi_pass
chdir=/wwwroot/destiny
module=destiny.wsgi
master = true         
processes=2
threads=2
max-requests=2000
chmod-socket=664
vacuum=true
daemonize =/wwwroot/destiny/uwsgi.log

  

5、启动nginx

6、启动uwsgi

7、测试

 

上一篇:TVM Relay与Pass


下一篇:接口和JAVA设计模式