My guess is: when the script is been executed the user is www-data, so 'MY_VAR_NAME' is not accessible.
Your guess is correct. :)
Is there any procedures / best practices to this kind of problems ?
What most programmers would do is to have a configuration file containing these variables. You would store the configuration file in some area where the PHP scripts could get to it -- whether that's in a home directory somewhere, in /etc. or in some other place such as in the web root or a directory near it.
Different frameworks take different approaches to the format of the configuration files -- some are PHP scripts, some are YAML files, some are windows/DOS format INI files, some are XML, some are JSON, etc.
Personally I like the idea of doing this:
- Store in a simple INI file only the configuration required to access the database.
- Store all of the remaining configuration in a database table, and build an editor for the parts that you need to be able to edit.
- Cache the contents of the configuration database table in memcached.
Whichever method you use is up to you, however, and will vary depending on the needs of your application.
SetEnv MY_VAR_NAME value_goes_herein a .htaccess or .conf file.