Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: How to get path to a config file from the config file itself |
|
Author |
|
VEG
Joined: 20 Dec 2020 Posts: 4 Location: Belarus
|
Posted: Sun 20 Dec '20 17:44 Post subject: How to get path to a config file from the config file itself |
|
|
Currently, we have to define absolute path to the ServerRoot.
Code: | Define SRVROOT "c:/Apps/Web/Apache64php80"
ServerRoot "${SRVROOT}" |
It might be not convenient. Is there a way to define this path relative to the current httpd.conf or relative to the httpd.exe?
I wish it were something like this:
Code: | Define SRVROOT "${HTTPD_PATH}/../.."
ServerRoot "${SRVROOT}" | or:
Code: | Define SRVROOT "${HTTPD_DIR_PATH}/.."
ServerRoot "${SRVROOT}" |
Can it be done somehow? |
|
Back to top |
|
tangent Moderator
Joined: 16 Aug 2020 Posts: 348 Location: UK
|
Posted: Mon 21 Dec '20 23:29 Post subject: |
|
|
I'm not aware of any built-in system variables that would let you do this.
However, you could do something like this in the configuration file to set ServerRoot at start up.
Code: | # Define SRVROOT if APACHE_ROOT defined.
#
<IfDefine APACHE_ROOT>
Define SRVROOT ${APACHE_ROOT}
</IfDefine>
# Default SRVROOT if APACHE_ROOT not defined.
#
<IfDefine !APACHE_ROOT>
Define SRVROOT C:/Apache24
</IfDefine>
ServerRoot "${SRVROOT}" |
Then define an environment variable with the desired server root directory, and get Apache to pick that up using the -D option at start up, e.g.
Code: | set APACHE_ROOT=C:/Apps/Web/Apache64php80
httpd -t -D APACHE_ROOT |
To pass this environment variable to an Apache service instance, you'd need to create the following type of registry entry for the service, viz:
Key: HKLM\SYSTEM\CurrentControlSet\Services\Apache2.4
Value Name: Environment
Type: REG_MULTI_SZ
Data: APACHE_ROOT=C:/Apps/Web/Apache64php80 and add " -D APACHE_ROOT" to the service ImagePath entry.
You could pass additional environment variables conditionally to the Apache configuration using a similar technique.
Last edited by tangent on Wed 13 Jan '21 16:11; edited 1 time in total |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Tue 29 Dec '20 0:01 Post subject: |
|
|
Additional to tangent post
Use httpd -S it will show the current variables. |
|
Back to top |
|
|
|
|
|
|