Elastic Beanstalk,配置永远不会运行?

时间:2017-08-21 07:56:36

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

我正致力于通过弹性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登录。谁知道为什么?

1 个答案:

答案 0 :(得分:0)

/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部分有一些重复的行。