35

I need to set my apache environment to 'foobar'

I know I need to set in in my vhost, but what should I type there and where?

MatthewMartin
  • 32,326
  • 33
  • 105
  • 164
baklap
  • 2,145
  • 6
  • 28
  • 41

2 Answers2

70

SetEnv sets a particular variable to some value, so you need something like

SetEnv varname varvalue

If this is for a specific virtual host, and you have access to the Apache configuration files, this would go inside the <VirtualHost> directive for that virtual host.

If you don't have control of the config files, you'll need to put it in a .htaccess file. But for this to work, SetEnv must be allowed in .htaccess files, which is specified using the AllowOverride directive.

Richard Fearn
  • 25,073
  • 7
  • 56
  • 55
  • I have never done or used Apache and now as I am setting up Git with Smart HTTP protocol I have this little problem. In the manual they are talking about a command such as `SetEnv GIT_PROJECT_ROOT /opt/git`. In the linux I don't have an access to a command called `SetEnv` but `setenv`. I quite frankly don't know where should I be putting this command in. Would you be able to give me a hint? – Mehrad Apr 23 '15 at 05:50
  • 3
    `SetEnv` isn't a command you type in a terminal. It's a directive you put into the Apache configuration files. You should probably create a new question that describes your environment. – Richard Fearn Apr 23 '15 at 08:12
  • Thanks for your answer. I definitely will. I figured that one the hard way. :) As I said I know nothing about Apache and in general very little about Linux. Cheers – Mehrad Apr 24 '15 at 02:04
  • @Mehrad, I would like to know if you have found the answer ? – Vasif Dec 22 '15 at 21:32
0

I came here because I configured a python/django WSGI environment. Loading modules and SetEnv'ing all day long. Did not work. The vars would just not show up.

What did work was this: https://gist.github.com/GrahamDumpleton/b380652b768e81a7f60c

Graham describes how to basically clone your wsgi.py file and then use a different one for each environment (production, test, dev) and setting your environment vars in there with os.environ['whatever'] = 'you like!'

Chris
  • 5,788
  • 4
  • 29
  • 40