【问题标题】:Elastic Beanstalk, configuration never ran?Elastic Beanstalk,配置从未运行?
【发布时间】:2018-01-29 05:19:29
【问题描述】:

我正在通过 elastic beanstalk 部署应用程序。

但是,我注意到配置文件从未运行过,我知道这一点:

我已经设置了一个文档根目录,当我通过 AWS 进行设置时,它是空的, 我设置了一个同样为空的环境变量,但是当它通过网站手动设置时,它们工作正常,在事件日志中(部署时)我显然应该看到输出表明配置已成功运行。我尝试了所有日志,但没有在任何地方提及。

我正在运行 Laravel 5.4,并且在项目的根目录中创建了 .ebextensions 文件夹。在里面我有 01-environment.config:

option_settings:
  aws:elasticbeanstalk:container:php:phpini:
    document_root: /public
    memory_limit: 512M
  aws:elasticbeanstalk:sqsd:
    HttpPath: /worker/queue
  aws:elasticbeanstalk:application:environment:
    APP_ENV: production
    APP_KEY: base64:MDKarorDueozTysvq50zDJET7es7MsVoTe3r001+xBs=
    APP_DEBUG: true

02-deploy.config

   container_commands:
      01-migrations:
        command: "php artisan migrate --force"
        command: "php artisan key:generate"
        command: "php artisan config:clear"
        command: "php artisan config:cache"

    files:
      "/opt/elasticbeanstalk/hooks/appdeploy/post/99_make_storage_writable.sh":
        mode: "000755"
        owner: root
        group: root
        content: |
          #!/usr/bin/env bash
          echo "Making /storage writeable..."
          chmod -R 777 /var/app/current/storage
          chmod -R 777 /var/app/current/bootstrap/cache
          if [ ! -f /var/app/current/storage/logs/laravel.log ]; then
              echo "Creating /storage/logs/laravel.log..."
   owner: root
    group: root
    content: |
      #!/usr/bin/env bash
      echo "Making /storage writeable..."
      chmod -R 777 /var/app/current/storage
      chmod -R 777 /var/app/current/bootstrap/cache
      if [ ! -f /var/app/current/storage/logs/laravel.log ]; then
          echo "Creating /storage/logs/laravel.log..."
          touch /var/app/current/storage/logs/laravel.log
          chown webapp:webapp /var/app/current/storage/logs/laravel.log
      fi

      if [ ! -d /var/app/current/public/storage ]; then
          echo "Creating /public/storage symlink..."
          ln -s /var/app/current/storage/app/public /var/app/current/public/sto$
      fi

  "/opt/elasticbeanstalk/tasks/publishlogs.d/laravel-logs.conf":
      chown webapp:webapp /var/app/current/storage/logs/laravel.log
      fi

      if [ ! -d /var/app/current/public/storage ]; then
          echo "Creating /public/storage symlink..."
          ln -s /var/app/current/storage/app/public /var/app/current/public/sto$
      fi

  "/opt/elasticbeanstalk/tasks/publishlogs.d/laravel-logs.conf":
    mode: "000755"
    owner: root
    group: root
    content: |
      /var/app/current/storage/logs/*.log

  "/etc/httpd/conf.d/https_redirect.conf":
    mode: "000644"
    owner: root
    group: root
  content: |
      /var/app/current/storage/logs/*.log

  "/etc/httpd/conf.d/https_redirect.conf":
    mode: "000644"
    owner: root
    group: root
    content: |
      RewriteEngine on
      RewriteCond %{HTTP:X-Forwarded-Proto} ^http$
      RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=307,L]

如您所见,我在这里也进行了重定向,这不起作用,因为它默认始终使用 http,我没有在 S3 或任何其他命令上获取 laravel 登录。有谁知道为什么?

【问题讨论】:

    标签: laravel amazon-web-services laravel-5 amazon-elastic-beanstalk


    【解决方案1】:

    /var/log/eb-activity.log 应该显示您正在执行的 .config 文件。

    在您的02-deploy.config 中,有几个问题。

    • container_commands 下,每个command: 只能有一个命令。试试这样的:

      container_commands:
        01-migrations:
          command: "php artisan migrate --force"
        02-generate-key:
          command: "php artisan key:generate"
        03-config-clear:
          command: "php artisan config:clear"
        04-config-cache:
          command: "php artisan config:cache"
      
    • 您的空格不一致。 YAML 文件对空格非常敏感,因此请确保每个级别使用相同数量的缩进(通常是两个空格)。

    • 可能只是复制/粘贴问题,但99_make_storage_writable.sh 部分有一些重复的行。

    【讨论】:

      猜你喜欢
      • 2020-02-28
      • 2015-06-18
      • 1970-01-01
      • 1970-01-01
      • 2017-01-07
      • 2015-02-23
      • 2020-08-17
      • 2020-08-27
      • 2013-08-23
      相关资源
      最近更新 更多