问题描述
我使用Python和Django在本地机器上构建了一个应用程序。它的工作很好现在,我想自动化在生产服务器上启动Django应用程序的过程。我要做什么来实现?
strong> Django文档不建议在生产时使用Django内置服务器。
建议使用或发布您的WSGI应用程序:
-
-
另一个好的做法是使用启动你的进程,然后如果它因某种原因死亡或死亡,supervisord将重新启动此过程。
要完成,请使用 或 作为代理服务器,它们是强大的服务器,可以处理收费。大部分的教程或文档,建议使用nginx,因为它是一个高性能的HTTP服务器。
请检查这一点,了解如何配置它们:
-
-
在部署Django应用程序之前,请阅读此清单,以确保一切都配置良好:
这个架构和工具,您将能够使用一个简单的 supervisord
命令启动你的炮弹进程。就这样。然后爆米花将启动您的WSGI应用程序。
I built an application on my local machine with Python and Django. Its working fine. Now, I would like to automate the process to start my Django application on a production server.
What I have to do to achieve that?
Django documentation don't recommend to use Django built-in server on production.
It's recommended to use gunicorn or uWSGI to launch your WSGI application :
- How to use Django with gunicorn
- How to use Django with uWSGI
Another good practice, it's to use supervisord to start your process, Then if it dies or get killed for some reason, supervisord will restart this process.
And to finish, use nginx or apache as proxy server, which are strong server that can handle the charge. Most of tutorials or documentations, recommend to use nginx because it's a high-performance HTTP server.
Check this to know how to configure them :
- Deploying Gunicorn with nginx
- Deploying uWSGI with nginx
Also before deploy your Django app, read this checklist, to make sure everything is well configured : Django - Deployment checklist
With this architecture and tools, you will be able to launch your gunicorn process with a simple supervisord
command. That's all. Then gunicorn will launch your WSGI application.
这篇关于如何在生产服务器上自动运行我的Django应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!