0

在部署 Elastic Beanstalk 应用程序期间,尝试从 Elastic Beanstalk 将 .conf 文件添加到 E2 实例上的 /etc/httpd/conf.d/ 目录。我在 .ebextensions 目录中添加了一个 .config 文件,该文件定义如下:

files:
  "/etc/php.d/project.ini" :
    mode: "000644"
    owner: root
    group: root
    content: |
      max_input_vars = 10000
      upload_max_filesize = 256M
      post_max_size = 256M

container_commands:
  01_enable_mod_deflate:
    command: "cp .ebextensions/enable_mod_deflate.conf /etc/httpd/conf.d/enable_mod_deflate.conf"
  02_enable_mod_expires:
    command: "cp .ebextensions/enable_mod_expires.conf /etc/httpd/conf.d/enable_mod_expires.conf"
  03_secure_wordpress:
    command: "cp .ebextensions/secure_wordpress.conf /etc/httpd/conf.d/secure_wordpress.conf"
  04_restart_apache:
    command: "sudo apachectl restart"

.conf 文件都在 .ebextensions 文件夹中,但它们没有被复制,这导致 .htaccess 在 wordpress 站点的根目录中出现问题。正在生成的错误如下所示:

命令 01_enable_mod_deflate (cp /var/app/current/.ebextensions/enable_mod_deflate.conf /etc/httpd/conf.d/enable_mod_deflate.conf) 失败 2020-10-05 13:45:59,944 [错误] 在构建 postbuild_0_Benefits_Bridge_2 期间遇到错误:命令 01_enable_mod_deflate 失败 Traceback(最近一次调用最后):文件“/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py”,第 542 行,在 run_config CloudFormationCarpenter(config, self._auth_config).build(工作日志)文件“/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py”,第 260 行,在构建更改 ['commands'] = CommandTool().apply(self._config.commands) 文件“ /usr/lib/python2.7/site-packages/cfnbootstrap/command_tool.py",第 117 行,在应用中引发 ToolError(u"Command %s failed" % name) ToolError: Command 01_enable_mod_deflate failed

不知道这甚至意味着什么,但它会为每个文件生成相同的错误。这里有什么问题?我刚刚启动了一个新的 Elastic Beanstalk 实例,默认情况下不应该这样做吗?实例有问题吗?由于根目录中的 .htaccess 文件,该站点生成 500 错误,但如果我将其删除,则只有主页加载,所有其他页面都会出现 404 错误。我需要将这些 .conf 文件添加到所有实例的 /etc/httpd/conf.d/ 目录中,但由于上述错误,它们根本没有添加到任何实例中,我不知道如何修复,或者如果这是使用 Elastic Beanstalk 创建的默认实例的问题?

如何解决这个问题?我已经重新启动了环境,但这并没有帮助。我对重建环境有点犹豫,因为这会清除连接到应用程序的数据库,并且不确定这是否会有所帮助。

4

1 回答 1

2

您可能正在使用更改了代理(NGINX 或 Apache)配置文件位置的 Amazon Linux 2。将您的代理配置文件放在.platform而不是.ebextensions下:例如:

|____wp-signup.php
|____.platform
| |____httpd
| | |____conf.d
| | | |____http-redirect.conf

文档中的更多详细信息:

将您的 Elastic Beanstalk Linux 应用程序迁移到 Amazon Linux 2

于 2020-12-20T00:34:17.470 回答