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





PhazzAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

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

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.