logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in  RSS Apache Lounge  


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

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.



Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: How to get path to a config file from the config file itself
Author
VEG



Joined: 20 Dec 2020
Posts: 2
Location: Belarus

PostPosted: Sun 20 Dec '20 17:44    Post subject: How to get path to a config file from the config file itself Reply with quote

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



Joined: 16 Aug 2020
Posts: 39
Location: UK

PostPosted: Mon 21 Dec '20 23:29    Post subject: Reply with quote

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: 6890
Location: Germany, Next to Hamburg

PostPosted: Tue 29 Dec '20 0:01    Post subject: Reply with quote

Additional to tangent post

Use httpd -S it will show the current variables.
Back to top


Reply to topic   Topic: How to get path to a config file from the config file itself View previous topic :: View next topic
Post new topic   Forum Index -> Apache