Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I would like to add a linux environment variable for my differents applications written in PHP and Ruby.

Its goal is to differntiate between 'production' and 'development' linux environment.

How to have an linux environment variable (ex : APPLICATION_ENV='production') that can be accessed with PHP and Ruby?

thanks

Edit 1 :

My first solution was :

for Apache/PHP in vhost :

SetEnv APPLICATION_ENV 'production'

for Ruby :

export APPLICATION_ENV='production'
puts ENV['APPLICATION_ENV']

However, this is two places to the same value... There are no solution to merge it in one place ? par exemple to use /etc/environment

share|improve this question
add comment

2 Answers

Just add the export line to your ~/.bashrc:

export APPLICATION_ENV='production'

Then, if you want to change it, run this from the terminal:

export APPLICATION_ENV='development'
share|improve this answer
    
PHP with Apache, can use this variable ? –  Bastien D Jul 4 '13 at 14:17
add comment

You could write the code you used in a function for both which accepts the variable name and the value.

Then just call your custom_env_variable('APPLICATION_ENV','production'); when you need it. Basically suggesting a wrapper.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.