Thx for the reply.
If I understand the gist of what you propose, it consists of setting environment variables that specify the Apache bin path, and its log path. Those env vars can then be accessed in the conf file using the ${VARIABLE} syntax.
I guess that would do the trick, thx. But I was hoping for a more automated way. It seems kind of silly to setup conf variables to tell the httpd.conf file stuff about the instance of Apache that’s compiling it in the first place. You would think that there would be a syntax for retrieving that more directly.
Oh well.
Alain
From: marcos [mailto:chipcmc@gmail.com]
Sent: Wednesday, January 25, 2012 10:32 AM
To: users@httpd.apache.org
Subject: Re: [users@httpd] Can you tell the path of Apache in httpd.conf?
Define one file wiht variables definition, name file examplo =setVarApache.env in path /tmp
$more setVarApache.env
LOG_PATH=/tmp/example/
LISTENIP=192.168.100.1
NAMESERVER=MyServer
LISTENPORT=82
Now in script to start apache i charge this file with:
. /tmp/setVarApache.env
case $ARGV in
stop|restart|graceful)
$HTTPD -f /opt/apache2/httpd.conf -k $ARGV
ERROR=$?
;;
start|startssl|sslstart|start-SSL)
$HTTPD -f /opt/apache2/httpd.conf -k start -DSSL
ERROR=$?
;;
configtest)
$HTTPD -f /opt/apache2/httpd.conf -t
ERROR=$?
;;
status)
$LYNX $STATUSURL | awk ' /process$/ { print; exit } { print } '
;;
fullstatus)
$LYNX $STATUSURL
;;
list)
$HTTPD -f /opt/apache2/httpd.conf -S 2>&1 | grep namevhost | awk '{print $4}'
;;
*)
$HTTPD -f /opt/apache2/httpd.conf $ARGV
ERROR=$?
esac
and in httpd.conf
<VirtualHost ${LISTENIP}:${LISTENPORT}>
ServerName $NAMESERVER
CustomLog "|/opt/apache2/bin/rotatelogs ${LOG_PATH}/access-${SERVERNAME}.log 86400" wusage
</VirtualHost>
if you has diferente machines, you can use name of host in name of file:
setEnv_HOSTNAME.env
at this way you can use the same script:
. setVarApache_$(uname -n)
2012/1/25 Desilets, Alain <Alain.Desilets@nrc-cnrc.gc.ca>
A related question to the one I posted earlier about env variables.
In my httpd.conf, I want to setup some custom error logs for my application, using a statement like this:
ErrorLog "|[apachepath]/bin/rotatelogs.exe -l [apachepath]/logs/error_blah.log 86400"
The problem is that I would have to hardcode the apachepath, which is something I want to avoid (since it may vary on different dev machines).
Is there a way to know what that is?
The only way we have found to do this is to use <Perl> sections with statements like these:
---
my $path_to_logs = catfile Apache2::ServerUtil::server_root, qw(logs);
my $path_to_bin = catfile Apache2::ServerUtil::server_root, qw(bin);
---
It works, but I would prefer a solution that does not involve <Perl> sections (since they are harder to read and debug).
Thx.
Alain Désilets
Agent de recherche | Research Officer
Institut de technologie de l'information | Institute for Information Technology Conseil national de recherches du Canada | National Research Council of Canada
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org