

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 在 Elastic Beanstalk 上使用 Procfile 設定應用程式程序。
<a name="ruby-platform-procfile"></a>

欲指定啟動 Ruby 應用程式的命令，請於原始碼套件的根目錄，納入名為 `Procfile` 的檔案。

**注意**  
Elastic Beanstalk 在 Amazon Linux AMI Ruby 平台分支 (Amazon Linux 2 之前的分支) 上不支援此功能。含有 *with Puma* 或 *with Passenger* 名稱的平台分支，不論其 Ruby 版本為何，都會優先於 Amazon Linux 2 且不支援 `Procfile` 功能。

如需撰寫和使用 的詳細資訊`Procfile`，請參閱 [Buildfile 和 Procfile](platforms-linux-extend.build-proc.md)。

當您不提供 時`Procfile`，Elastic Beanstalk 會產生預設 `Procfile`。如果您的 `Gemfile`包含 Puma，Elastic Beanstalk 會假設您想要使用您提供的 Puma 版本，並產生下列預設 `Procfile`。

```
web: bundle exec puma -C /opt/elasticbeanstalk/config/private/pumaconf.rb
```

如果您的 `Gemfile` 不包含 Puma，Elastic Beanstalk 會假設您使用預先安裝的 Puma 應用程式伺服器，並產生下列預設 `Procfile`。在 Amazon Linux 2 Ruby 平台分支上，`Procfile`如果您不提供 ，Elastic Beanstalk 一律會產生下列預設值`Procfile`。

```
web: puma -C /opt/elasticbeanstalk/config/private/pumaconf.rb
```

**注意**  
[2024 年 10 月 10](https://docs.aws.amazon.com/elasticbeanstalk/latest/relnotes/release-2024-10-10-al2-10-2024-retire.html) 日，最後一個 Ruby Amazon Linux 2 平台分支已淘汰。所有目前[支援的 Ruby 平台分支](https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platforms-supported.html#platforms-supported.ruby)都以 Amazon Linux 2023 為基礎。如需遷移的相關資訊，請參閱 [從 Amazon Linux 2 遷移到 Amazon Linux 2023](using-features.migration-al.generic.from-al2.md)。

如果你想使用 Passenger 應用程式伺服器，請使用下面的範例檔案，設定 Ruby 環境來安裝和使用 Passenger。

1. 使用此範例檔案安裝 Passenger。  
**Example Gemfile**  

   ```
   source 'https://rubygems.org'
   gem 'passenger'
   ```

1. 使用此範例檔案，指示 Elastic Beanstalk 啟動 Passenger。  
**Example Procfile**  

   ```
   web: bundle exec passenger start /var/app/current --socket /var/run/puma/my_app.sock
   ```

**注意**  
您不必更改 nginx 代理伺服器組態中的任何內容，即可使用 Passenger。要使用其他應用程序伺服器，您可能需要自訂 nginx 組態，以適當地將請求轉送到應用程式。