• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5538
  • Last Modified:

How to work with SetEnv in httpd.conf

How can I use variables in httpd.conf, essentially like this bash-inspired pseudo-code:

SetEnv BASE_DIR /the/basic/path/to/something
SetEnv FOO_DIR ${BASE_DIR}/foo
SetEnv BAR_DIR ${BASE_DIR}/bar

It should do the same as this:

SetEnv DIR_FOO /the/basic/path/to/something/foo
SetEnv DIR_BAR /the/basic/path/to/something/bar





0
Phazz
Asked:
Phazz
  • 4
  • 2
3 Solutions
 
farzanjCommented:
You have to include or uncomment mod_env library.

Also, for scripts you may want to set ScriptAlias for their paths.
0
 
PhazzAuthor Commented:

Thanks. The mod_env library is included.

I need to combine and concatenate the values of some environment variables and write them back in other environment variables. I'm maintaining some old CGI webapps which need to acsess those env.vars, and it is not only paths for scripts.

What is the syntax (in httpd.conf) for reading the value of an environment variable? Like my ${BASE_DIR} in my pseudo-code example.
0
 
larsrohrCommented:
Are all the environmental variables to be created or read as you start Apache?
If so, you would add to your envvars file.  In Ubuntu, you might find this at /etc/apache2/envvars.
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
farzanjCommented:
Try this:
SetEnv NEW_PATH %{ENV:BASE_DIR}/my/path

Open in new window

0
 
PhazzAuthor Commented:
Unfortunately %{ENV:BASE_DIR} is not being expanded, I mean NEW_PATH gets the litteral value %{ENV:BASE_DIR}/my/path .
0
 
PhazzAuthor Commented:
In the link http://www.issociate.de/board/goto/1147159/Using_environment_variable_in_httpd.conf.htm ,
I see a reference to a  book Pro Apache 3rd edition, by Peter Wainwright. Apparently it is possible to a have a <perl> ... </perl> section in the httpd.conf. That could probably solve my problem. But it requires the mod_perl module to be enabled in Apache, and my web admin said it is overkill and he doesn't want to do that. Well, he's probably right!

I will close the question and distribute the points 4/5 to farzanj and 1/5 to larsrohr.

Ciao!
0
 
PhazzAuthor Commented:
None of the experts gave me a real solution but it made me realize the implications.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now