
本文共 3634 字,大约阅读时间需要 12 分钟。
���Docker���������������������Python3 + uWSGI + Nginx���Django���������
���������������Django���������������������������������Django���������web������������������python manage.py runserver
������������������������������������������������������������Nginx + uWSGI������������������������������������������������������������������������������Django���������������unaugmented���������������������������������������
������������������������������
���������������������������������������������������
������Python3���������������Docker���������
1.������Python3���������������
docker pull python:3.6
2.������Python3������
docker run -itd -v /project:/opt --rm --name python3env python:3.6
-v /project:/opt
���������������������������������������������/opt
������������-itd
������������������������interactive mode���������������������������������--name python3env
������������������������������������������
���������������������������������������������������������
docker exec -it python3env bash
3.������Django������������������
���������������������������������
pip install django-guardian mysqlclient jira PyYAML
������Django������������
1. ���������������������
���������������settings.py
���������
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'mysql', 'USER': 'root', 'PASSWORD': '123456789', 'HOST': '192.168.63.128', 'PORT': '3306', }}
2. ������������������������
���settings.py
������������������������
CORS_ALLOW_CREDENTIALS = TrueCORS_ORIGIN_ALLOW_ALL = TrueCORS_ORIGIN_WHITELIST = ()CORS_ALLOW_METHODS = ( 'DELETE', 'GET', 'OPTIONS', 'PATCH', 'POST', 'PUT', 'VIEW')CORS_ALLOW_HEADERS = ( 'accept', 'accept-encoding', 'authorization', 'content-type', 'dnt', 'origin', 'user-agent', 'x-csrftoken', 'x-requested-with')
uWSGI���������������
1. ������uWSGI
���������������������������
pip install uwsgi -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
2. ������uWSGI������������
���������������������������uwsgi.ini
���������������������������������
[uwsgi]wsgi.chdir = ./autotpsite.wsgi:applicationhttp=0.0.0.0:8081master=truepidfile=./uwsgi8081.piddaemonize=./uwsgi_server.logsocket-timeout=10
3. ������uWSGI
���������������������
uwsgi uwsgi.ini
Nginx���uWSGI���������������������
1. ������������IP
���������������������������������������������
ip addr
������������������������bridge
������������������Docker���docker0
���������
2. ������������������IP
docker network inspect bridge
3. ������Nginx������������
���������������conf
������������������default.conf
���������������������������
location / { proxy_pass http://192.168.63.128:3306; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme;}
������������������
������������������������
python manage.py runserver
- ������������������������������������
- ������Nginx������������������������uWSGI������������������
- ������Python���������IP������������������
������������
������������������������������Docker���������������������uWSGI������Django������������������������������������Nginx������������������������������������������������
������������������������������������������������������������������������Django���������������������
发表评论
最新留言
关于作者
