如何使用 Python 3.11 64 位 Amazon Linux 2023 部署到 AWS Elastic Beanstalk

问题描述 投票:0回答:1

我正在尝试将一个简单的 Flask 应用程序部署到 Elastic beanstalk。我能够部署示例版本。然而,我目前正在努力部署自己的。我的Python应用程序已命名为application.py,并将代码中的flask名称更改为代码中的“application”。我的 .ebextension 文件内包含以下内容:

postgres.config:

packages:
    yum:
        mariadb-devel: []
        postgresql-devel: []

(编辑:删除了 mariadb-devel。现在说 postgres 无法安装。更多信息如下)

python.config:

commands:
  01_update_pip:
    command: "pip install --upgrade pip setuptools"

option_settings:
  aws:elasticbeanstalk:container:python:
    WSGIPath: application.py

我正在使用AWS网站进行部署。我是半新人,仍在弄清楚。我的目录如下所示:

  • 服务器(根)
    • .ebextensions - postgres.config - python.config
    • 应用程序.py
    • 需求.txt
  • venv

在日志中一些值得注意的事情:

[INFO] Error occurred during build: Yum does not have postgresql-devel available for installation
[ERROR] An error occurred during execution of command [app-deploy] - [PreBuildEbExtension]
[WARN]could not build optimal types_hash, you should increase either types_hash_max_size: 1024 or types_hash_bucket_size: 64; ignoring types_hash_bucket_size

我尝试运行另一个命令,该命令似乎至少可以部署在 Amazon Linux 2 中,但出现错误的网关错误。可悲的是,我已经不记得了。另外,如果可能的话,我更愿意坚持使用最新版本。如果以不同的方式尝试更容易,那就可以了。

python amazon-web-services flask amazon-ec2 amazon-elastic-beanstalk
1个回答
0
投票

Elastic Beanstalk 的文档未针对 AL2023 进行更新,并且仍使用 AL2,因此如果您想使用 AL2023,请不要只遵循 Elastic beanstalk 文档。

我不认为他们有 AL2023 的 postgresql-devel 包,基于这个 link 已安装的包列表。另外,他们将包管理器从 yum 更改为 dnf,即使 yum 应该仍然可以工作,我建议在您的文件中将 yum 更改为 dnf。

如果可以的话,最好通过 ssh 进入已部署的 Elastic beanstalk 实例并输入“dnf search”来获取您搜索的包的确切名称。正如链接这里

© www.soinside.com 2019 - 2024. All rights reserved.