简体   繁体   English

Laravel Elastic Beanstalk 运行迁移

[英]Laravel Elastic Beanstalk running migrations

I have setup elastic beanstalk for my laravel application.我为我的 laravel 应用程序设置了弹性豆茎。 I use environment properties:我使用环境属性:

在此处输入图像描述

The application works fine, but when I run migrations this fails as the creds for the db have not been added to.env file (I wanted to run the migrations using ebextensions).该应用程序运行良好,但是当我运行迁移时,由于数据库的凭据尚未添加到 .env 文件中(我想使用 ebextensions 运行迁移),因此失败。 Is there a way to run migrations where it uses environment properties?有没有办法在使用环境属性的地方运行迁移?

The migrations run as part of the deployment.迁移作为部署的一部分运行。

I also ran into this problem.我也遇到了这个问题。 The proper solution is to not use environment properties within the EB console.正确的解决方案是不在 EB 控制台中使用环境属性。 I put my.env on a S3 bucket and copy it in on deploy.我将 my.env 放在 S3 存储桶上,并在部署时将其复制。 This also helps with maintaining ENV variables between for ex.这也有助于维护 for ex 之间的 ENV 变量。 green/blue deployments and if you ever need to upgrade EB environment platforms (for ex. when a new PHP/Python/NodeJS version is released or Amazon Linux version)绿色/蓝色部署以及您是否需要升级 EB 环境平台(例如,当发布新的 PHP/Python/NodeJS 版本或 Amazon Linux 版本时)

This an example for an ebextension which copies over.env variables from S3: https://github.com/rennokki/laravel-aws-eb/blob/master/.ebextensions/00_copy_env_file.config这是从 S3 复制 over.env 变量的 ebextension 示例: https://github.com/rennokki/laravel-aws-eb/blob/master/.ebextensions/00_copy_env_file.config

You could also copy your.env file from the deployment folder to where your project is located with this script您还可以使用此脚本将您的 .env 文件从部署文件夹复制到项目所在的位置

sudo cp /opt/elasticbeanstalk/deployment/env /var/www/html/.env && sudo chown ec2-user:webapp .env && sudo chmod 644 .env
  • copy over env file from deployment folder with cp使用cp从部署文件夹复制 env 文件
  • change user and group of file with chown使用chown更改用户和文件组
  • change file rights with chmod使用chmod更改文件权限

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM