You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Brolin Empey <br...@brolin.be> on 2009/10/06 20:37:05 UTC

[users@httpd] how to avoid duplicating the document root in vhost conf files?

Hello list,

Here is one of my vhost conf files:

[brolin@cowboy] [0] [1] ~/
$ cat /etc/apache2/sites-available/aidsorphanage.org
<VirtualHost *:80>
        ServerAdmin brolin@techsol.ca
        ServerName aidsorphanage.org
        ServerAlias www.aidsorphanage.org aidsorphonage.org
www.aidsorphonage.org

        DocumentRoot /var/www/aidsorphanage.org/

#       FIXME: How can I avoid duplicating ${DOCUMENT_ROOT}?
#              - brolin, 2009-09-15
        <Directory "/var/www/aidsorphanage.org/logs/">
                Order Deny,Allow
                Deny from All
        </Directory>

        <Directory />
                Options FollowSymLinks
                AllowOverride All
        </Directory>

        ErrorLog /var/www/aidsorphanage.org/logs/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/www/aidsorphanage.org/logs/access.log combined
</VirtualHost>
[brolin@cowboy] [0] [2] ~/

How can I avoid duplicating the document root after it is declared
with the DocumentRoot directive?  In this example, the document root
is duplicated thrice.  Duplication is bad.

I am using apache2 version 2.2.11-2ubuntu2.3.

Thanks,
Brolin

--
Sometimes I forget how to do small talk: <http://xkcd.com/222/>

“If you have to ask why, you’re not a member of the intended
audience.” — Bob Zimbinski, <http://webpages.mr.net/bobz/ttyquake/>

---------------------------------------------------------------------
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


Re: [users@httpd] how to avoid duplicating the document root in vhost conf files?

Posted by Krist van Besien <kr...@gmail.com>.
You might want to take a look at mod_macro. Especially if you have a
lot of VHOSTS, and have them all structured in the same way.

http://www.cri.ensmp.fr/~coelho/mod_macro/

Krist

-- 
krist.vanbesien@gmail.com
krist@vanbesien.org
Bremgarten b. Bern, Switzerland
--
A: It reverses the normal flow of conversation.
Q: What's wrong with top-posting?
A: Top-posting.
Q: What's the biggest scourge on plain text email discussions?

---------------------------------------------------------------------
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


Re: [users@httpd] how to avoid duplicating the document root in vhost conf files?

Posted by Brolin Empey <br...@brolin.be>.
2009/10/6 Jonathan Zuckerman <j....@gmail.com>:
> Ah I see... I'm a software engineer too so I appreciate trying to
> encapsulate often-used values but I'd say this might be one of those
> battles it wouldn't kill you to forfeit.

I am a hacker, not an engineer. ;)  In any case, I am not a
professional engineer, so I would not call myself an engineer.

Anyway, did you notice my FIXME about avoiding the duplicated paths is
dated 2009-09-15?  I have already deferred publicly asking about this
issue for over half a month because it is a low priority and I am
probably the only person who cares about it, but I am a perfectionist
sometimes, so I want to avoid the duplication.

> That said, have you tried using relative paths for the error log path
> declarations?

No, I have not.  Since the ${DOCUMENT_ROOT} variable exists, why can I
not use it in my vhost conf file? :(

>  Or (my preferred solution) put them outside the
> document root; why bother putting them in the doc root and then making
> a directory override to disallow outside access to them when the
> simpler solution would be to just put them outside the web root and
> never ever worry about access rules.

I know that is a simpler and probably more logical solution, but I
kept the logs under the doc root for at least 2 reasons:

1. The Web howto about configuring apache2 vhosts on Debian/Ubuntu I
used used this config in its examples.  That howto lacks credibility,
though, because it has errors (singular versus plural nouns) in the
paths to the vhost conf files and does not even prevent world/public
access to the logs!  (epic fail)

2. Because my VPS is hosting multiple vhosts, I thought it was tidier
to keep the logs in the doc root.  I know it does not make much sense
because the logs are not public content, but it was an arbitrary
decision:  I had to keep the logs /somewhere/.  Yes, I suppose
/var/log/ is a better home for apache logs than /var/www/.



I mean this completely politely, but you should trim your quotes to
include only relevant text, not entire messages, including signatures
and footers.

---------------------------------------------------------------------
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


Re: [users@httpd] how to avoid duplicating the document root in vhost conf files?

Posted by Jonathan Zuckerman <j....@gmail.com>.
On Tue, Oct 6, 2009 at 12:30 PM, Brolin Empey <br...@brolin.be> wrote:
> 2009/10/6 Jonathan Zuckerman <j....@gmail.com>:
>> Am I missing something? I only see the DocumentRoot declared once in
>> your example
>
> Yes, there is only 1 DocumentRoot directive, but the
> “/var/www/aidsorphanage.org/” part of the /value/ of the DocumentRoot
> directive is duplicated thrice.  How can I avoid duplicating this
> common part of the paths in the vhost conf file?
>
> ---------------------------------------------------------------------
> 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
>
>

Ah I see... I'm a software engineer too so I appreciate trying to
encapsulate often-used values but I'd say this might be one of those
battles it wouldn't kill you to forfeit.
That said, have you tried using relative paths for the error log path
declarations?  Or (my preferred solution) put them outside the
document root; why bother putting them in the doc root and then making
a directory override to disallow outside access to them when the
simpler solution would be to just put them outside the web root and
never ever worry about access rules.

---------------------------------------------------------------------
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


Re: [users@httpd] how to avoid duplicating the document root in vhost conf files?

Posted by Brolin Empey <br...@brolin.be>.
2009/10/6 Jonathan Zuckerman <j....@gmail.com>:
> Am I missing something? I only see the DocumentRoot declared once in
> your example

Yes, there is only 1 DocumentRoot directive, but the
“/var/www/aidsorphanage.org/” part of the /value/ of the DocumentRoot
directive is duplicated thrice.  How can I avoid duplicating this
common part of the paths in the vhost conf file?

---------------------------------------------------------------------
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


Re: [users@httpd] how to avoid duplicating the document root in vhost conf files?

Posted by Jonathan Zuckerman <j....@gmail.com>.
On Tue, Oct 6, 2009 at 11:37 AM, Brolin Empey <br...@brolin.be> wrote:
> Hello list,
>
> Here is one of my vhost conf files:
>
> [brolin@cowboy] [0] [1] ~/
> $ cat /etc/apache2/sites-available/aidsorphanage.org
> <VirtualHost *:80>
>        ServerAdmin brolin@techsol.ca
>        ServerName aidsorphanage.org
>        ServerAlias www.aidsorphanage.org aidsorphonage.org
> www.aidsorphonage.org
>
>        DocumentRoot /var/www/aidsorphanage.org/
>
> #       FIXME: How can I avoid duplicating ${DOCUMENT_ROOT}?
> #              - brolin, 2009-09-15
>        <Directory "/var/www/aidsorphanage.org/logs/">
>                Order Deny,Allow
>                Deny from All
>        </Directory>
>
>        <Directory />
>                Options FollowSymLinks
>                AllowOverride All
>        </Directory>
>
>        ErrorLog /var/www/aidsorphanage.org/logs/error.log
>
>        # Possible values include: debug, info, notice, warn, error, crit,
>        # alert, emerg.
>        LogLevel warn
>
>        CustomLog /var/www/aidsorphanage.org/logs/access.log combined
> </VirtualHost>
> [brolin@cowboy] [0] [2] ~/
>
> How can I avoid duplicating the document root after it is declared
> with the DocumentRoot directive?  In this example, the document root
> is duplicated thrice.  Duplication is bad.
>
> I am using apache2 version 2.2.11-2ubuntu2.3.
>
> Thanks,
> Brolin
>
> --
> Sometimes I forget how to do small talk: <http://xkcd.com/222/>
>
> “If you have to ask why, you’re not a member of the intended
> audience.” — Bob Zimbinski, <http://webpages.mr.net/bobz/ttyquake/>
>
> ---------------------------------------------------------------------
> 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
>
>

Am I missing something? I only see the DocumentRoot declared once in
your example

---------------------------------------------------------------------
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