简体   繁体   English

在AWS上部署Django应用

[英]Deploying django app on aws

I'm quite new to python and I have developed a simple app using django which I want to deploy to aws. 我是python的新手,我使用django开发了一个简单的应用程序,希望将其部署到aws。 I followed the steps presented in [this][1] 我遵循了[this] [1]中介绍的步骤

[1]: https://code.google.com/archive/p/modwsgi/wikis/QuickConfigurationGuide.wiki link to install the same. [1]: https//code.google.com/archive/p/modwsgi/wikis/QuickConfigurationGuide.wiki链接进行安装。 I have installed apache and mod_wsgi. 我已经安装了apache和mod_wsgi。 python version on aws is 2.7. aws上的python版本是2.7。 The mod_wsgi that I have installed is: mod_wsgi-python27-3.2-6.11.amzn1.x86_64. 我已经安装的mod_wsgi是:mod_wsgi-python27-3.2-6.11.amzn1.x86_64。 I have added LoadModule directive in httpd.conf. 我在httpd.conf中添加了LoadModule指令。 Yet I get an error : ImportError: No module named django.core.wsgi when I hit one of the end points of my app. 但是我遇到了一个错误:ImportError:当我碰到应用程序的终点之一时,没有名为django.core.wsgi的模块。 Any clues around what might be the issue? 有关可能是什么问题的任何线索? I have tried looking up at existing solutions for this problem but none of them seems to be fixing the issue. 我尝试查找该问题的现有解决方案,但似乎都没有解决该问题。 Is there something that I'm missing? 有什么我想念的吗?

You can use many web server and app server to deploy Django app but here in this tutorial all instruction are given step by step and there is a video tutorial as well to guide through all the instruction to deploy the django app using Nginx , vritualenv , gunicorn . 您可以使用许多Web服务器和应用服务器部署Django应用程序,但这里在本教程的所有指令给出了一步一步的还有视频教程 ,以及通过所有的指令,指导部署使用Django的应用程序Nginxvritualenvgunicorn

Hope this is helpful for newbies. 希望这对新手有帮助。

Have you installed Django on the instance? 您是否在实例上安装了Django? It looks like Django is either not installed or is not being picked up. 看起来Django尚未安装或未被拾取。

If you you using a virtualenv, you'll need to add the path to it in your config file: 如果您使用virtualenv,则需要在配置文件中添加路径:

WSGIPythonPath /path/to/mysite.com:/path/to/your/venv/lib/python2.7/site-packages

Here is some more documentation from Django and mod_wsgi that may help: 这是Django和mod_wsgi的其他一些文档,可能会有所帮助:

https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/modwsgi/ https://modwsgi.readthedocs.org/en/develop/getting-started.html https://docs.djangoproject.com/zh-CN/1.9/howto/deployment/wsgi/modwsgi/ https://modwsgi.readthedocs.org/en/develop/getting-started.html

This is one of the most daunting tasks, especially if you want to deploy it with celery and migrations. 这是最艰巨的任务之一,特别是如果您想通过celery和迁移进行部署。

I suggest you use AWS Elastic Beanstalk, a managed to deploy your django app. 我建议您使用AWS Elastic Beanstalk,这是一种可部署django应用程序的托管方法。 You can use container commands to run migrations before each deployment too. 您也可以在每次部署之前使用容器命令来运行迁移。

The following tutorial worked really well for me: https://www.trysudo.com/deploying-django-app-on-aws-using-elastic-beanstalk/ 以下教程对我来说确实非常有效: https//www.trysudo.com/deploying-django-app-on-aws-using-elastic-beanstalk/

You can deploy with nginx and gunicorn. 您可以使用nginx和gunicorn进行部署。 There is a great example to do this: How To Install and Configure Django with Postgres, Nginx, and Gunicorn 有个很好的例子: 如何使用Postgres,Nginx和Gunicorn安装和配置Django。

and one more: Setting up Django with Nginx, Gunicorn, virtualenv, supervisor ... 还有一个: 用Nginx,Gunicorn,virtualenv,supervisor设置Django ...

I hope this will help. 我希望这将有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM