aws v2.2.exe

by Evrim Persembe

通过埃夫里姆·佩塞姆贝

如何在AWS Elastic Beanstalk上部署Rails 5.2 PostgreSQL应用 (How to deploy a Rails 5.2 PostgreSQL app on AWS Elastic Beanstalk)

It’s official, using Heroku for all my Rails projects so far has spoiled me rotten. After receiving some AWS credits thanks to a pitch competition, I decided to deploy my latest project on Elastic Beanstalk (AWS’ Heroku competitor). All I have to say is that I miss Heroku.

官方的说法 ,到目前为止,在我所有的Rails项目中使用Heroku都使我很烂。 在一次激烈的竞争中获得了一些AWS积分后,我决定在Elastic Beanstalk ( AWS的Heroku竞争对手)上部署我的最新项目。 我只想说我想念Heroku。

Alas, if you are in a similar situation, here are step-by-step instructions to deploying your Rails 5.2 / PostgreSQL app on Elastic Beanstalk.

las,如果您的情况类似,这里是在Elastic Beanstalk上部署Rails 5.2 / PostgreSQL应用程序的分步说明。

安装Elastic Beanstalk CLI (Installing the Elastic Beanstalk CLI)

We will use the terminal in this tutorial. Let’s begin with installing the “Elastic Beanstalk Command Line Interface.” Here is how to do it on macOS using Homebrew:

我们将在本教程中使用终端。 让我们从安装“ Elastic Beanstalk命令行界面”开始。 这是使用Homebrew在macOS上执行操作的方法:

brew install awsebcli

If you are using another platform, googling “how to install awsebcli on [your platform]” should lead you in the right direction.

如果您使用的是其他平台,则搜索“如何在[您的平台]上安装awsebcli”可以引导您朝正确的方向发展。

初始化Elastic Beanstalk (Initializing Elastic Beanstalk)

I will assume that you already have an Amazon Web Services account, if not go ahead and create one. Now, go into the directory of your project, and initialize Elastic Beanstalk:

我将假设您已经有一个Amazon Web Services帐户,如果没有,请继续创建一个。 现在,进入项目目录,并初始化Elastic Beanstalk:

cd my_projecteb init

Then the EB CLI will ask you a few questions to initialize the Elastic Beanstalk application. The initialization part is straightforward. If you get stuck anywhere you can check out the “Configure the EB CLI” page from the documentation.

然后,EB CLI将询问您一些问题来初始化Elastic Beanstalk应用程序。 初始化部分很简单。 如果您卡在任何地方,都可以从文档中查看“配置EB CLI”页面。

创造新环境 (Creating a new environment)

As you already know, your application can have many environments (think of them as different configurations). For example, you might have a “production” environment. This is the environment that you use for the user-facing version of your app. But you might want to have another environment named “staging.” This is where you try new versions of your app, before pushing it to the production environment.

如您所知,您的应用程序可以具有许多环境(将它们视为不同的配置)。 例如,您可能有一个“生产”环境。 这是您用于应用程序的面向用户版本的环境。 但是您可能想要另一个名为“ staging”的环境。 在将应用推送到生产环境之前,您可以在这里尝试新版本的应用。

We can create an environment using the command below:

我们可以使用以下命令创建环境:

eb create production

部署到Elastic Beanstalk (Deploying to Elastic Beanstalk)

Assuming you are using Git, commit your changes before deploying your application. The EB CLI deploys your last commit. If you deploy before committing, you will deploy an earlier version of your app.

假设您正在使用Git,请在部署应用程序之前提交更改。 EB CLI会部署您的最后一次提交。 如果在提交之前进行部署,则将部署应用程序的早期版本。

After committing your changes, deploy using the following:

提交更改后,请使用以下内容进行部署:

eb deploy

So far so good, now we need to set a few things before our app actually starts working.

到目前为止,到目前为止,我们需要在应用程序实际开始工作之前进行一些设置。

设置主密钥 (Setting up the master key)

You can use the CLI for this purpose as well, but I prefer using the web panel for this. Here is how:

您也可以为此使用CLI,但是我更喜欢使用Web面板。 方法如下:

  1. Go to AWS, choose “Services -> Elastic Beanstalk,” then click on your environment.转到AWS,选择“服务-> Elastic Beanstalk”,然后单击您的环境。
  2. Open the “Configuration” tab, and click “Modify” under the box titled “Software.”打开“配置”选项卡,然后在标题为“软件”的框下单击“修改”。
  3. Under “Environment properties,” add a new key named RAILS_MASTER_KEY. Set its value to the content of your “master.key” file. You can find this file in the “config” directory of your Rails app.

    在“环境属性”下,添加一个名为RAILS_MASTER_KEY的新密钥。 将其值设置为“ master.key”文件的内容。 您可以在Rails应用程序的“ config”目录中找到此文件。

  4. Click on the “Apply” button at the bottom of the page.单击页面底部的“应用”按钮。

设置PostgreSQL数据库 (Setting up a PostgreSQL database)

Elastic Beanstalk provides an easy way to set up a database, which you can reach through “Configuration -> Database.” I prefer not to use that because if you need to rebuild your Elastic Beanstalk environment, your database will be deleted. So, we will set up the database separate from our Elastic Beanstalk environment.

Elastic Beanstalk提供了一种建立数据库的简便方法,您可以通过“配置->数据库”来访问它。 我不想使用它,因为如果您需要重建Elastic Beanstalk环境,则数据库将被删除。 因此,我们将与Elastic Beanstalk环境分开设置数据库。

在RDS上创建PostgreSQL数据库 (Creating a PostgreSQL database on RDS)

  1. Go to AWS, choose “Services -> RDS.”转到AWS,选择“服务-> RDS”。
  2. Choose “Create database.”选择“创建数据库”。
  3. Choose “PostgreSQL,” and click “Next.”选择“ PostgreSQL”,然后单击“下一步”。
  4. Select your use case, “Production” or “Dev/Test,” and click “Next.”选择您的用例“生产”或“开发/测试”,然后单击“下一步”。
  5. Here, you can try different options, and see what the estimated monthly costs are. Settle with something that is within your budget. You can start with a db.t2.micro instance, no multi-AZ deployment and a general purpose SSD.

    在这里,您可以尝试其他选项,并查看估计的每月费用。 用您预算范围内的东西解决。 您可以从db.t2.micro实例开始,无需多db.t2.micro区部署和通用SSD。

  6. Choose an instance identifier, this is sort of a “namespace.”选择一个实例标识符,这就是一种“命名空间”。
  7. Choose a username and password, keep these handy for now, click “Next.”选择一个用户名和密码,暂时保留它们,单击“下一步”。
  8. On the “Configure advanced settings” section, the important thing is the security groups. Select “Choose existing VPC security groups,” and select the security group that looks like “…-AWSEBSecurityGroup-…”在“配置高级设置”部分,重要的是安全组。 选择“选择现有的VPC安全组”,然后选择类似于“ ...- AWSEBSecurityGroup -...”的安全组。
  9. Pick a database name, such as my_app_production.

    选择一个数据库名称,例如my_app_production

  10. Click on “Create database,” this will take a while.点击“创建数据库”,这将需要一段时间。

允许访问数据库 (Allowing access to the database)

In the meantime, let’s add Postgres access to your security group:

同时,让我们向您的安全组添加Postgres访问权限:

  1. Go to AWS, choose “Services -> EC2.”转到AWS,选择“服务-> EC2”。
  2. Click on “Security Groups” on the left panel.单击左侧面板上的“安全组”。
  3. Choose the security group from the previous section.从上一节中选择安全组。
  4. Go to the “Inbound” tab, and click on “Edit.”转到“入站”选项卡,然后单击“编辑”。
  5. Click on “Add Rule.” For “Type,” choose “PostgreSQL,” and for “Source” type in the ID of the security group that you are adding this rule to. It should be right above the “Inbound” tab and should look like sg-*.

    点击“添加规则”。 对于“类型”,选择“ PostgreSQL”,对于“源”,输入要添加此规则的安全组的ID。 它应该在“入站”选项卡的正上方,并且应该看起来像sg-*

  6. Click “Save.”点击“保存”。

设置生产数据库配置 (Setting up the production database configuration)

Now, in your Rails directory, open config/database.yml. Change it as such:

现在,在您的Rails目录中,打开config/database.yml 。 这样更改:

# ...
production:  <<: *default  database: <%= ENV['RDS_DB_NAME'] %>  username: <%= ENV['RDS_USERNAME'] %>  password: <%= ENV['RDS_PASSWORD'] %>  host: <%= ENV['RDS_HOSTNAME'] %>  port: <%= ENV['RDS_PORT'] %>

将相关环境变量添加到Elastic Beanstalk (Adding relevant environment variables to Elastic Beanstalk)

We told Rails to get the information for the production database using the above environment variables. Now we need to make sure that our Elastic Beanstalk environment includes these variables:

我们告诉Rails使用上述环境变量来获取生产数据库的信息。 现在,我们需要确保我们的Elastic Beanstalk环境包含以下变量:

  1. Go to AWS, choose “Services -> Elastic Beanstalk,” then click on your environment.转到AWS,选择“服务-> Elastic Beanstalk”,然后单击您的环境。
  2. Open the “Configuration” tab, and click “Modify” under the box titled “Software.”打开“配置”选项卡,然后在标题为“软件”的框下单击“修改”。
  3. Under “Environment properties,” add the following key-value pairs:在“环境属性”下,添加以下键值对:
  4. RDS_DB_NAME: Database name you picked when setting up your database.

    RDS_DB_NAME :设置数据库时选择的数据库名称。

  5. RDS_USERNAME: Username you picked when setting up your database.

    RDS_USERNAME :设置数据库时选择的用户名。

  6. RDS_PASSWORD: Password you picked when setting up your database.

    RDS_PASSWORD :设置数据库时选择的密码。

  7. RDS_HOSTNAME: Go to “Services -> RDS,” and you can find this information under the “Connect” section of your database instance information page. It is called “Endpoint.”

    RDS_HOSTNAME :转到“服务-> RDS”,您可以在数据库实例信息页面的“连接”部分下找到此信息。 它称为“端点”。

  8. RDS_PORT: Set this to 5432.

    RDS_PORT :将此设置为5432。

  9. Click on the “Apply” button at the bottom of the page.单击页面底部的“应用”按钮。

After this, commit your Rails app directory again, and run eb deploy. You might want to wait a few minutes before doing this because Elastic Beanstalk does some stuff in the background after updating environment variables.

之后,再次提交您的Rails应用程序目录,然后运行eb deploy 。 您可能需要等待几分钟,因为执行更新环境变量后,Elastic Beanstalk在后台执行了一些操作。

After these steps, your Rails app “should” be running.

完成这些步骤后,“应”运行Rails应用程序。

还是行不通? (Still not working?)

If there are any issues, you can go to your EB environment on the AWS web panel, click on “Logs,” and choose “Request Logs -> Last 100 Lines” to see the logs. But before doing that, I’d recommend trying to run your Rails app using the production environment on your local machine by using the command rails s RAILS_ENV=production.

如果有任何问题,您可以在AWS Web面板上转到EB环境,单击“日志”,然后选择“请求日志->最后100行”以查看日志。 但是,在此之前,我建议您尝试使用本地nd rails s RAILS_ENV=product ion在本地计算机上的生产环境中运行Rails应用程序。

I’ll be the first to admit that I’m not the most experienced person when it comes to deployment. As I said, I always used Heroku in the past, and I probably will use it for my future projects as well. These steps worked for me after a few days of scratching my head trying to set up my Rails app on Elastic Beanstalk, so I wanted to share these in hopes of saving time for people who are in the same situation I was. So, take this all with a grain of salt, and good luck!

我将是第一个承认我在部署方面不是最有经验的人。 就像我说的那样,我过去一直使用Heroku,将来我也可能会使用它。 经过几天的努力,尝试在Elastic Beanstalk上设置我的Rails应用程序之后,这些步骤对我有用。因此,我想与大家分享这些信息,以期为处于同样状况的人们节省时间。 因此,带上一粒盐和好运来带走这一切!

If you like this article, follow me on Twitter or sign up to my newsletter to get notified when I write new articles. I write about software and startups.

如果您喜欢这篇文章,请在Twitter上关注我或注册我的新闻通讯,以在我撰写新文章时得到通知。 我写有关软件和创业公司的文章。

If you are looking for a Rails developer, I’m currently available for remote work. Feel free to get in touch with me at hi{at}evrim.io.

如果您正在寻找Rails开发人员,那么我现在可以进行远程工作。 欢迎访问hi {at} evrim.io与我联系。

Originally published at evrim.io on November 28, 2018.

最初于2018年11月28日发布在evrim.io上。

翻译自: https://www.freecodecamp.org/news/how-to-deploy-a-rails-5-2-postgresql-app-on-aws-elastic-beanstalk-34e5cec3a984/

aws v2.2.exe

aws v2.2.exe_如何在AWS Elastic Beanstalk上部署Rails 5.2 PostgreSQL应用相关推荐

  1. 在Amazon Elastic Beanstalk上部署Spring Boot应用程序

    在此博客中,我们将看到如何在Amazon ElasticBeanstalk上部署Spring Boot应用程序. Amazon ElasticBeanstalk具有一个预配置的Java环境,可用于部署 ...

  2. node aws 内存溢出_在AWS Elastic Beanstalk上运行生产Node应用程序的现实

    node aws 内存溢出 by Jared Nutt 贾里德·努特(Jared Nutt) 在AWS Elastic Beanstalk上运行生产Node应用程序的现实 (The reality o ...

  3. aws部署java应用_在 Elastic Beanstalk 上创建和部署 Java 应用程序 - AWS Elastic Beanstalk...

    本文属于机器翻译版本.若本译文内容与英语原文存在差异,则一律以英文原文为准. 在 Elastic Beanstalk 上创建和部署 Java 应用程序 AWS Elastic Beanstalk 支持 ...

  4. aws部署php程序,在 Elastic Beanstalk 上创建和部署 PHP 应用程序 - AWS Elastic Beanstalk

    AWS 文档中描述的 AWS 服务或功能可能因区域而异.要查看适用于中国区域的差异,请参阅中国的 AWS 服务入门. 本文属于机器翻译版本.若本译文内容与英语原文存在差异,则一律以英文原文为准. 在 ...

  5. aws v2.2.exe_如何使用Python 3.6在AWS EC2上创建运行uWSGI,NGINX和PostgreSQLDjango服务器...

    aws v2.2.exe by Sumeet Kumar 通过Sumeet Kumar 如何使用Python 3.6在AWS EC2上创建运行uWSGI,NGINX和PostgreSQLDjango服 ...

  6. aws beanstalk mysql_在AWS Elastic Beanstalk上连接到Mysql

    我是一个相对较新的LAMP开发人员,他主要通过AWS学习Linux.我有一个实时的Elastic Beanstalk实例启动并运行.我做了以下软件包的yum安装: mysql55.x86_64 mys ...

  7. 【AWS】一、如何在AWS免费撸一年的服务器

    AWS - 亚马逊公司旗下云计算服务平台 之前有幸参加了aws培训学习,现在给大家介绍一些aws的使用方法 本文介绍先介绍如何在aws免费使用aws的服务器资源 1.注册/登陆 官网:https:// ...

  8. 如何在tomcat下应用部署日志_如何在kubernete集群上部署springboot应用

    1.打包springboot镜像 2.在kubernete上发布镜像 3.测试 在之前的文章中,我讲了使用kubeadm从0到1搭建kubernete集群,今天我们来聊一下如何在这套k8s集群上部署s ...

  9. aws部署ssh_将Quarkus应用程序部署到AWS Elastic Beanstalk

    aws部署ssh Elastic Beanstalk允许在AWS云中部署和管理应用程序,而无需了解运行这些应用程序的基础架构. 使用Elastic Beanstalk,您可以运行可处理HTTP请求的网 ...

最新文章

  1. wfs方式获取最短路径
  2. 理科大学二本计算机系,大学最好就业的二本专业:高校男生女生二本理科比较好的专业...
  3. js实现图片加载特效(从左到右,百叶窗,从中间到两边)
  4. Springboot项目搭建(前端到数据库,超详细,附详细步骤截图)
  5. Vultr 修改 Root 密码
  6. usleep头文件_Linunx的sleep,usleep,select,nonasleep对比与应用
  7. java-练习2:MobilePhone
  8. 基于 FastAPI 的房源租赁系统设计与实现
  9. arduino智能浇花系统_基于Arduino单片机的智能浇花器
  10. 15、三维表面重建-Occupancy Networks
  11. 根据传函求频率响应、根据实验的频率响应求传函、Nyquist图、bode图
  12. pygraphviz win7安装报错解决
  13. 一键训练 deeplabv3seg、squeezeseg、voxelnet Docker镜像安装
  14. windows10驱动 x64--- 3环代码加载驱动(二)
  15. 万字总结,一文带你秒懂Java中的封装、继承和多态(有代码 有示例)
  16. 阿里云dataworks/maxcomputer和自建集群的对比
  17. Android源码修改后的语音录音代码
  18. 是男人就坚持20秒—python版本
  19. 传智播客python视频百度云盘下载_传的解释|传的意思|汉典“传”字的基本解释...
  20. 2023 手术机器人现状

热门文章

  1. MMKV集成与原理,成功跳槽阿里!
  2. go build编译不同环境
  3. php 常用正则运算
  4. C++ 网络开发工具
  5. PHPCMS的产品筛选功能
  6. 【系统架构理论】一篇文章精通:Spring Cloud Netflix Eureka
  7. Django框架是什麼?
  8. [微信小程序] 当动画(animation)遇上延时执行函数(setTimeout)出现的问题
  9. iOS:通信录(完成)(18-01-18更)
  10. 【JavaScript】apply和call的区别在哪?