Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

257
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda