Setting environment variables for accessing in PHP when using Apache


I have a Linux environment and I have a PHP Web Application that conditionally runs based on environment variables using getenv in PHP. I need to know how these environment variables need to be set for the application to work correctly. I am not sure how to set this up on Apache.

Also, I need to be able to configure separate environment variables for each domain separately.

Please advice on how can I achieve this.

This question is tagged with php apache ubuntu environment-variables

~ Asked on 2012-06-05 18:01:27

The Best Answer is


Something along the lines:

<VirtualHost hostname:80>
   SetEnv VARIABLE_NAME variable_value

~ Answered on 2012-06-05 18:05:26


You can also do this in a .htaccess file assuming they are enabled on the website.

SetEnv KOHANA_ENV production

Would be all you need to add to a .htaccess to add the environment variable

~ Answered on 2012-06-05 18:08:47

Most Viewed Questions: