Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

241
Vistas
EC2 instances of ElasticBeanstalk are not retrieving the .env variables set in the Beanstalk console for Laravel application in terminal/ ssh

I am deploying a Laravel application to the ElasticBeanstalk. Now, I am trying to SSH into the EC2 instance of my Beanstalk environment and run a command.

php artisan migrate --force

But I cannot run it. The command is failing because it is not getting the environment variables set in the Beanstalk Environment. Here is what I did.

I ssh into the instance. Then I go to the /var/www/html folder. Then I run the "php artisan migrate --force" command. As I mentioned it is failing because it is not getting the database credentials set in the Beanstalk environment. I also tried this.

sudo -u root php artisan migrate --force

The same thing happened. I also played around with tinker in the terminal. When I retrieve the app name like env('APP_NAME'), it is returning null. What is the issue and how can I fix it?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

The command is failing because it is not getting the environment variables set in the Beanstalk Environment.

On Amazon Linux 2 (AL2), the EB env variables are stored in /opt/elasticbeanstalk/deployment/env. Thus when you ssh to your EB instance, you can use the following to populate your env variables (need to sudo to root firs):

sudo su 
export $(cat /opt/elasticbeanstalk/deployment/env | xargs)
echo $YOU_ENV_NAME_FORM_EB 

This is undocumented way of doing this on AL2.

Note:

The env variables shouldn't have spaces. Also the file is not immediately available. It gets created when deployment succeeds.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda