Amazon Web Services 上的 Django 入门

发布于 2024-10-08 14:43:38 字数 1539 浏览 3 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

情栀口红 2024-10-15 14:43:38

EC2 没有什么“特别”之处。它只提供裸系统实例(或者通常从自定义 AMI 预配置)系统实例 - 您可以访问整个虚拟化系统,因此您可以安全地自行破坏系统。将其视为特定的 VPS。

您必须自己准备部署,这并不困难 - 只需按照文档进行操作即可。我建议使用基本的 Linux 发行版运行并添加所需的内容,而不是依赖某些预配置的映像。至于你的问题:

  1. 你需要做两件事:设置实例(帐户、所需的软件、其他自定义设置,因此一些 Linux 管理指南应该很方便)并准备 django 应用程序部署(部署 python 代码,连接到网络服务器)。对于后者,可以在此处应用 django 的一般部署说明 ( http://docs. djangoproject.com/en/dev/howto/deployment/)。

  2. 从 AMI 与您最喜欢的 Linux 发行版开始,然后从其存储库添加必要的软件。

  3. 尽快为您的所有数据安装并使用 EBS。重新启动时,EC2 实例将清除其所有数据,因此请为此做好准备。对 AMI 进行系统快照,以便在发生故障时快速恢复。

是的,您可以在一个实例上部署多个应用程序,但请注意 EC2 实例是虚拟化的(在我看来,“虚拟化税”相当高,特别是对于较小的实例),因此您可能会遇到一般性能问题。假设您需要在一段时间后迁移到更大的实例/多个实例。

Virtualenv 应该是您的默认部署工具。是的,您也可以在这里使用它。

There is nothing "special" with EC2 here. It just provides bare (or generally preconfigured from custom AMI) system instance - you have access to whole virtualized system, so you can safely break things on your own. Think about it as a specific VPS.

You have to prepare deployment by yourself, which is not so difficult - just follow the documentation. I'd advice to run with basic linux distro and add needed stuff than to rely on some preconfigured image. As for you questions:

  1. You need to do two things: setup your instance (accounts, needed software, other custom setup, so some linux administration guide should be handy) and prepare django app deployment (deploy python code, hook up to web server). For the latter, general deployment instructions for django can be applied here ( http://docs.djangoproject.com/en/dev/howto/deployment/ ).

  2. Start with AMI with your favorite linux distro, and then add necessary software from it's repository.

  3. Mount and use EBS as soon as possible for all your data. When rebooted, EC2 instance will wipe out all it's data, so be prepared for this. Do system snapshots to AMI to have quick recovery on failure.

Yes, you can deploy several applications on one instance, but mind that EC2 instance is virtualized (with quite high "virtualization tax" imo, especially for smaller instances), so you might run into general performance problems. Assume that you'd need migrate to bigger instance/multiple instances after some time.

Virtualenv should be your default deployment tool. Yes, you can use it here too.

清泪尽 2024-10-15 14:43:38

您可以按照设置 Amazon ec2 实例的官方文档进行操作: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-launch-instance_linux.html

您应该从您熟悉的 AMI 开始。例如,如果您使用 Ubuntu,则可以仅使用推荐页面中的 Ubuntu AMI 之一。我没有使用 BitNami 服务器,我的 Django 站点部署顺利。

如果您使用 Apache 服务器,只需按照 Django 官方文档上的说明进行操作:
https://docs.djangoproject.com/en/1.5/howto/部署/wsgi/modwsgi/

我尝试了很多博客,但正如你所说,它们已经过时了。只需使用官方文档即可,这将为您节省大量时间。

You can follow the official documentation of setting up Amazon ec2 instance: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-launch-instance_linux.html

You should start with an AMI that you are familiar with. For example, if you use Ubuntu, you can just use one of the Ubuntu AMI in the recommended page. I didn't use the BitNami server and my Django site is deployed smoothly.

If you are using Apache server, just follow the instructions on the official Django doc:
https://docs.djangoproject.com/en/1.5/howto/deployment/wsgi/modwsgi/

I tried quite a few blogs but as you said, they are outdated. Just use the official docs and it will save you a lot of time.

仅此而已 2024-10-15 14:43:38

此存储库旨在准确解决此问题 - 为可部署到 AWS ElasticBeanstalk 上的基本 django 项目提供参考实现。

https://github.com/pushkarparanjpe/django-awsome

它有:

  • 静态资产
  • 数据库后台 - end
  • django contrib Admin

只需配置您的 EBS 环境,克隆存储库并部署!

This repo is meant to address exactly this issue - provide a reference implementation for a basic django project that can be deployed onto AWS ElasticBeanstalk.

https://github.com/pushkarparanjpe/django-awsome

It has:

  • Static assets
  • DB back-end
  • django contrib Admin

Just configure your EBS env, clone the repo and deploy!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文