

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 在 Elastic Beanstalk 上使用 Gemfile 安装程序包
<a name="ruby-platform-gemfile"></a>

要使用 RubyGems 来安装应用程序所需的软件包，请在项目源代码的根目录中加入一个`Gemfile`文件。

**Example Gemfile**  

```
source "https://rubygems.org"
gem 'sinatra'
gem 'json'
gem 'rack-parser'
```

如果 `Gemfile` 文件存在，Elastic Beanstalk 将运行 `bundle install` 以安装依赖项。有关更多信息，请参阅 Bundler.io 网站上的 [Gemfiles](https://bundler.io/man/gemfile.5.html) 和 [Bundle](https://bundler.io/man/bundle.1.html)（捆绑包）页面。

**注意**  
除了 Ruby 平台预装的默认版本外，还可以使用其他版本的 Puma。为此，请在 `Gemfile` 中包含指定版本的条目。您还可以使用自定义的 `Gemfile` 来指定不同的应用程序服务器，例如 Passenger。  
对于这两种情况，您都需要配置 `Procfile` 以启动应用程序服务器。  
有关更多信息，请参阅*[使用 Procfile 配置应用程序进程](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/ruby-platform-procfile.html)**。*