[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Apache config database generated



> Dear List,
>
> I was wondering if there are tools/libs which handle the complete
> apache config with all it's directives etc.. I found some apache
> virtual host tools which can add <virtual hosts:80> but no tools/libs
> which can do the whole thing except Webmin but that's not something I
> can use.
>
> As Apache is the most used Webserver in the world, there must be some
> good opensource libs/tools there for it's configuration file. Some
> CPAN modules handle httpd.conf but those still require me to write
> a lot for just parsing the file.
>
> Maybe I'm just lazy.

Maybe..

create conf.tpl file
----------------
############################################################################
####
# Main Configuration
############################################################################
####

ServerType standalone
User apache
Group webmaster
...
...
...
[%
############################################################################
#
   BLOCK virtual_host %]
<VirtualHost [% ServerIP || 'your server IP' %]:*>
  ServerName [% ServerName %]
  [% IF ServerAlias %]ServerAlias [% ServerAlias %][% END %]
  DocumentRoot /usr/web/[% ServerName %]/data
  [% content %]
</VirtualHost>
[% END %]

[%
############################################################################
#
   BLOCK simple_virtual_host %]
<IfModule mod_accel.c>
[% WRAPPER virtual_host %]
  [% INCLUDE standart_log %]
  [% content %]
[% END %]
</IfModule>
[% END %]

[%
############################################################################
#
   BLOCK perl_virtual_host %]
[% WRAPPER virtual_host %]
  <IfModule mod_accel.c>
    RewriteEngine On
#    RewriteLogLevel 9
#    RewriteLog /tmp/rewrite
  </IfModule>
  <IfModule mod_perl.c>
    PerlPostReadRequestHandler My::ProxyRemoteAddr
    <Perl>
      use lib qw(/usr/web/[% ServerName %]/modules);
    </Perl>
  </IfModule>
  [% content %]
[% END %]
[% END %]
...
other BLOCKs of your common config parts
...

[% IF apache_type == 'production' %]
[% PROCESS /usr/local/apache/conf/hosts.tpl %]
[% ELSE %]
[% PROCESS /usr/local/apache/conf/hosts_d.tpl %]
[% END %]
(END)
----------------
create hosts.tpl file
----------------
[%
############################################################################
#
   ServerName='www.servername.com' %]

[% WRAPPER perl_virtual_host %]
  [% INCLUDE stat_access %]
  [% INCLUDE standart_log %]
  [% INCLUDE authentication %]
  [% INCLUDE apache_jaf_handler ModuleName='Apache::JAF::Scat' %]
  [% INCLUDE apache_jaf_handler Location='/manager'
ModuleName='Apache::JAF::Scat::Manager' ApacheJAFPrefix='/manager'
ApacheJAFAdditionalTemplates='/manager' %]
  [% INCLUDE mod_rewrite_file_not_exists %]
  [% INCLUDE accel_no_cache %]
[% END %]

...

other host configs
----------------
create httpbuild script
----------------
tpage --define apache_type="production" ~apache/conf/conf.tpl >
~apache/conf/httpd.conf
----------------

tpage is a program from Template::Toolkit package
(http://www.template-toolkit.org)

Restart Apache with httpdbuild && apachectl restart

your can write httpbuild script as database driven... You can do anything...
--------------------------------------------
Sergey Polyakov               aka "BeerBong"
Chief of WebZavod     http://www.webzavod.ru
Tel. +7 (8462) 43-93-85 | +7 (8462) 43-93-86
mailto:alexei@samara.net



Reply to: