- 时间:2021-08-09 19:22 编辑: 来源: 阅读:
- 扫一扫,手机访问
摘要:Ubuntu 14.04+Django 1.7.1+Nginx+uwsgi部署教程
具体环境:
Ubuntu 14.04 Python 2.7.6 Django 1.7.1 Virtualenv name:test Nginx uwsgi
假设 项目文件夹位于 /data/www/ts 设置保存在 ./conf
[url=http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html]http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html[/url]
首先,需要一个uwsgi_params文件,放在项目的conf文件夹里面。之后需要指向它。文件内容如下:
[url=http://example.cn:8000/media/1.gif]http://example.cn:8000/media/1.gif[/url]
了(事先放进去一个静态文件)
之后的blabla步骤都是废话,跳到这里:
Configuring uWSGI to run with a .ini file
ts_uwsgi.ini 在项目根目录
[uwsgi]
# Django-related settings
# the base directory (full path)
chdir = /data/www/ts
# Django's wsgi file
module = ts.wsgi
# the virtualenv (full path)
home = /root/.envs/test
# process-related settings
# master
master = true
# maximum number of worker processes
processes = 10
# the socket (use the full path to be safe
socket = 127.0.0.1:8001
# ... with appropriate permissions - may be needed
# chmod-socket = 664
# clear environment on exit
vacuum = true
# set an environment variable
env = DJANGO_SETTINGS_MODULE=conf.settings
uwsgi --ini mysite_uwsgi.ini # the --ini option is used to specify a file
这里环境变量设置env需要conf文件夹有init.py,否则conf不会被认为是module
(目前除了80端口,其他端口都可以通过地址:端口访问。已经测试8000,81.80测试不知道为什么不成。明天待续)
微信版

扫一扫进微信版
返回顶部