httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marcos <chip...@gmail.com>
Subject Re: [users@httpd] Can you tell the path of Apache in httpd.conf?
Date Wed, 25 Jan 2012 15:31:34 GMT
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
>
>

Mime
View raw message