

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

# 在 Elastic Beanstalk 上使用 Procfile 配置 WSGI 服务器
<a name="python-configuration-procfile"></a>

您可以将 [`Procfile`](platforms-linux-extend.build-proc.md#platforms-linux-extend.proc) 添加到源捆绑包，以指定和配置应用程序的 WSGI 服务器。您可以在 `Procfile` 中指定自定义启动和运行命令。

使用 `Procfile` 时，它会覆盖您使用配置文件设置的 `aws:elasticbeanstalk:container:python` 命名空间选项。

下面的示例使用 `Procfile` 将 UWSGI 指定为服务器并进行配置。

**Example Procfile**  

```
web: uwsgi --http :8000 --wsgi-file application.py --master --processes 4 --threads 2
```

下面的示例使用 `Procfile` 配置 Gunicorn（即默认 WSGI 服务器）。

**Example Procfile**  

```
web: gunicorn --bind :8000 --workers 3 --threads 2 project.wsgi:application
```

**注意**  
如果您配置 Gunicorn 之外的任何 WSGI 服务器，请确保还将该服务器指定为应用程序的依赖项，以便将安装在环境实例上。有关依赖项规范的详细信息，请参阅[在 Elastic Beanstalk 上使用要求文件指定依赖项](python-configuration-requirements.md)。
WSGI 服务器的默认端口为 8000。如果您在 `Procfile` 命令中指定了其他端口号，请将 `PORT` [环境属性](environments-cfg-softwaresettings.md)也设置为该端口号。