uWSGI安装配置与应用

基本部署流程草稿

Django简单基本部署流程:

	1. 租云服务器
	
	2. 买服务器
	
		租:公网IP,110.130.102.208
		租域名:www.python.com <-> 110.130.102.208
	
	3. 编写代码,打包程序
		
	
	4. 拷贝代码到服务器[Python,Django,pymysql,sqllite]
	
	
	5. 
		settings.py
			ALLOWED_HOSTS = ['服务器’,]或者*
		
		python manage.py runserver 0.0.0.0:8001
	
		使用:
			遵循wsig协议:
				wsgiref
	6. uwsgi
		pip3 intall uwsgi 
		
		
		简单测试:
			app.py
				def application(env, start_response):
					start_response('200 OK', [('Content-Type','text/html')])
					return [b"Hello World"]
					
			uwsgi --http :9001 --wsgi-file app.py

			uwsgi --http :9002 --wsgi-file foobar.py --master --processes 4 --threads 2
			
		Django:
			
			# 不处理静态文件
			uwsgi --http :9002 --chdir /data/s4/deploy --wsgi-file deploy/wsgi.py --master --processes 4 --threads 2  
			
			
			
			STATICFILES_DIRS = (
				os.path.join(BASE_DIR,'static'),
			)
			STATIC_ROOT = os.path.join(BASE_DIR,'uuuuuu')
			
			python manage.py collectstatic
			
			完事,注释静态配置
			
			# 处理静态文件
			uwsgi --http :9003 --chdir /data/s4/deploy --wsgi-file deploy/wsgi.py --static-map /static=/data/s4/deploy/uuuuuu
			
			
			# 写配置文件
				wsgi_http.ini
				    [uwsgi]
					http = 0.0.0.0:9004
					chdir = /data/s4/deploy
					wsgi-file = deploy/wsgi.py
					# processes = 4
					# threads = 2
					static-map = /static=/data/s4/deploy/uuuuuu
				uwsgi wsgi_http.ini
				
	7. Nginx
		
		yum install nginx
		
		/etc/init.d/nginx start/stop/restart
		
		/etc/nginx/nginx.conf	
		

  

 

posted @ 2017-09-27 17:34  Adamanter  阅读(166)  评论(0编辑  收藏  举报