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

249
Vistas
How to add environment variables to the apache user when executing a cron job / Yii2 controller in Amazon Linux 2?

I have developed a console controller in Yii2 for pulling in data and sending emails. My goal is to automate this task with crontab, which I have done using the yii2tech-crontab library. The issue I am experiencing is that the environment variables that I have set inside Apache configuration (inside our ssl.conf) do not apply when running things as the Apache user (say cron), but do work inside any of our website code.

What makes this a bit harder is that the apache user does not have a home directory (so I can't create a .profile), and I am unable to locate any sort of global apache user specific configuration.

One option would be to set these variables inside /etc/environment, however since these are sensitive credentials, I'd rather them not be accessible to other users.

I was able to add these environment variables to my current shell by creating a /etc/apache-environment file that was owned and grouped to apache, and then updating my cron entry to 0 8 * * * . /etc/apache-environment; php yii cron/task but php does not seem to pickup any of these credentials.

I have also tried setting php's variables_order to just load in environment (in case it was getting cleared) but that didn't change anything.

Are there any other options out there? Thanks for any feedback or help!

over 4 years ago · Santiago Trujillo
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