Gentoo Archives: gentoo-user

From: Alan <alan@×××××.org>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] dynamic apache configuration
Date: Fri, 15 Dec 2006 20:50:21
Message-Id: 20061215204923.GN29045@ufies.org
In Reply to: [gentoo-user] dynamic apache configuration by "Dmitry S. Makovey"
1 On Fri, Dec 15, 2006 at 11:58:50AM -0700, Dmitry S. Makovey wrote:
2 >
3 > Somewhat offtopic question, but here it goes:
4 >
5 > does anybody know of a module for apache that will use database to "suck in"
6 > part of apache http.conf file? What I need is dynamicaly manage my apache
7 > host with as few FS writes as possible. I remember seeing such a thing long
8 > time ago. Now I coudn't find it. mod_vhost doesn't cut it since I need full
9 > access to pretty muc all apache statements.
10
11 I know you can do this with mod_perl. Basically you can add a <perl>
12 </perl> block in the config file and populate it with pretty much any
13 perl command you need that end up outputing apache configuration info.
14
15 I've only used this in it's most basic form, an array of hostnames and a
16 foreach() that inserts the hostname into a preset block of text that's
17 printed out. IE:
18
19 <Perl>
20 #!perl
21 foreach my $host ( qw( foo bar baz) ) {
22
23 push @PerlConfig, <<EOF;
24 <VirtualHost xx.xx.169.216:80>
25 DocumentRoot /home/httpd/vhosts/${host}.com/
26 ServerName ${host}.com
27 ServerAlias www.${host}.com
28 DirectoryIndex index.html index.shtml index.htm index.php
29 CustomLog /usr/local/apache/logs/${host}-access.log common
30 ErrorLog /usr/local/apache/logs/${host}-error.log
31 [...] you get the picture
32 ScriptAlias /cgi-bin/ "/home/httpd/vhosts/${host}.com/cgi-bin/"
33 </VirtualHost>
34
35 EOF
36 }
37 __END__
38 </Perl>
39
40 Mod_Perl docs have more info, but that's the gist of it.
41
42
43
44 --
45 Alan <alan@×××××.org> - http://arcterex.net
46 --------------------------------------------------------------------
47 "Backups are for people who don't pray." -- big Mike

Replies

Subject Author
Re: [gentoo-user] dynamic apache configuration "Dmitry S. Makovey" <dmitry@××××××××××.ca>