Note - This question does not necessarily require any knowledge of AWS, it may purely be an Apache configuration issue.

I have a PHP application set up on a single AWS Elastic Beanstalk instance. I recently amended my configuration to allow for for SSL by adding a file called ssl.conf to /etc/httpd/conf.d, with the following contents:

<VirtualHost *:443>

  SSLEngine on
  SSLCertificateFile "/tmp/server.crt"
  SSLCertificateKeyFile "/tmp/server.key"

  SSLVerifyClient require
  SSLVerifyDepth 1
  SSLCACertificateFile "/tmp/origin-pull-ca.pem"

  LogFormat "%h (%{X-Forwarded-For}i) %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
  ErrorLog /var/log/httpd/elasticbeanstalk-error_log
  TransferLog /var/log/httpd/elasticbeanstalk-access_log


Since doing the above, for some reason, my environment variables (set in my Elastic Beanstalk configuration) are not being recognised when I make updates to them.

I have looked around my configurations and noticed that AWS sets the environment variables in a file called aws_env.conf which is also housed in the /etc/httpd.conf.d directory. The contents of this file looks something like this:

SetEnv RDS_DB_PASSWORD "somePassword"
SetEnv APP_ENV "production"

The Issue

For some very wierd reason, despite the values in aws_env.conf being up to date, none of the new values are being passed to my PHP application, it is still returning the values that I originally set when I created the instance.

It is almost as if Apache has cached the previously set environment variables and refuses to send the pass the new ones...

What's even weirder is that the built-in PHP $_SERVER variable is returning the correct values, whilst $_ENV is not...

Does anyone know what on earth is happening here?

I have tried restarting Apache and restarting the server. In fact, as a last resort, I have also just rebuilt the entire environment (something I wanted to avoid at all costs). Not sure if this has fixed it yet but will post back shortly...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.