Nginx+uwsgi部署django应用
2015-01-08 16:25
369 查看
Deploying Django
Django is very probably the most used Python web framework around. Deploying it is pretty easy (we continue our configuration with 4 processes with 2 threads each).django或许是最好用的python web框架了。部署十分的简单(我们继续我们的4处理器双线程配置)
We suppose the Django project is in /home/foobar/myproject:
假设django项目目录是/home/foobar/myproject:
uwsgi --socket 127.0.0.1:3031 --chdir /home/foobar/myproject/ --wsgi-file myproject/wsgi.py --master --processes 4 --threads 2 --stats 127.0.0.1:9191
(with --chdir we
move to a specific directory). In Django this is required to correctly load modules.
Argh! What the hell is this?! Yes, you’re right, you’re right... dealing with such long command lines is unpractical, foolish and error-prone. Never fear! uWSGI supports various configuration styles. In this quickstart we will use .ini files.
[uwsgi] socket = 127.0.0.1:3031 chdir = /home/foobar/myproject/ wsgi-file = myproject/wsgi.py processes = 4 threads = 2 stats = 127.0.0.1:9191
A lot better!
Just run it:
uwsgi yourfile.ini
If the file /home/foobar/myproject/myproject/wsgi.py (or
whatever you have called your project) does not exist, you are very probably using an old (< 1.4) version of Django. In such a case you need a little bit more configuration:
uwsgi --socket 127.0.0.1:3031 --chdir /home/foobar/myproject/ --pythonpath .. --env DJANGO_SETTINGS_MODULE=myproject.settings --module "django.core.handlers.wsgi:WSGIHandler()" --processes 4 --threads 2 --stats 127.0.0.1:9191
Or, using the .ini file:
[uwsgi] socket = 127.0.0.1:3031 chdir = /home/foobar/myproject/ pythonpath = .. env = DJANGO_SETTINGS_MODULE=myproject.settings module = django.core.handlers.wsgi:WSGIHandler() processes = 4 threads = 2 stats = 127.0.0.1:9191
Older (< 1.4) Django releases need to set env, module and
the pythonpath (.. allow
us to reach themyproject.settings module).
相关文章推荐
- Nginx+uWSGI+Django方法部署Django应用2
- ngingx+uwsgi+django项目部署nginx找不到django应用
- nginx + uwsgi + Django 应用部署
- 【转】Nginx+uWSGI 部署 Django 应用
- nginx+uwsgi+django+python 应用架构部署
- 使用nginx+uwsgi部署django应用
- Nginx+uWSGI部署Django应用
- 【金】nginx+uwsgi+django+python 应用架构部署
- ubuntu16.04使用nginx、uwsgi部署django应用
- 部署django时踩的坑 uwsgi + nginx 部署django应用
- uwsgi+django+nginx+supervisor部署web应用(python)
- 在部署django时踩的坑 uwsgi + nginx 部署django应用
- centos7 下通过nginx+uwsgi部署django应用
- nginx+uwsgi部署django应用
- Nginx+uwsgi部署django应用
- Nginx+uWSGI+Django方法部署Django应用1
- uwsgi+nginx部署 django应用
- 【NGINX】nginx+uwsgi+django+python部署总结
- Nginx+uWSGI+Django方法部署Django程序