1

I'm making a codeigniter website and i need to switch configs between production and development. By default Codeigniter searches for the var CI_ENV in PHP's $_SERVER superglobal. However when i'm trying to set my own with $ CI_ENV=production $ export CI_ENV in my production server.

When i'm trying to access it from $_ENV, $_SERVER or getenv() it's not there.

Why?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Meletis
  • 95
  • 4

1 Answers1

2

Afaik, Codeigniter looks for Apache ENV variables, not system variables.

In your vhosts.conf or .htaccess file add the following:

SetEnv CI_ENV production

If you add this to your vhosts.conf file you will need to restart Apache.

Mike Everhart
  • 408
  • 3
  • 10
  • Ahh, sorry, nginx wasn't mentioned in your post so I assumed it was Apache. Nginx doesn't really handle ENV variables by default, but there are some workarounds: http://nginx.org/en/docs/ngx_core_module.html#env and http://stackoverflow.com/a/8331663/5505288 might help. – Mike Everhart Oct 30 '15 at 20:24