User Tools

Site Tools


apachevhosts

DRAFT

Table Definitions

  1. vhost_directives (for apache <directive> definitions per vhost)
    • id(int)
    • parent(int)
    • directive(varchar)
    • value(varchar)
  2. vhost_settings (for apache “Key Value” definitions per vhost)
    • id(int)
    • directive_id(int)
    • position(int)
    • key(varchar)
    • value(varchar)
  3. vhost_fragments (for complete default code snippets that may occure in every vhost) can be used to enable/disable complete “features” of a vhost
    • id(int)
    • name(varchar)
    • code(text)

Sample data

{| border=“1” cellpadding=“2”

! id !! parent !! directive !! value

1 NULL VirtualHost
2 1 IfModule

{| border=“1” cellpadding=“2”

!id !! directive_id !! key !! position !! value

1 1 ServerName 1
2 1 DocumentRoot 2
3 2 RewriteEngine 1
4 2 RewriteRule 2

Pseudo code

vhost generation:

$vhosts = SELECT * FROM vhost_directives WHERE directive="VirtualHost";
foreach $vhosts as $vhost {
<code>
  start_vhost();
  $settings = SELECT * FROM vhost_settings WHERE directive_id=$vhost[['id']];
  add_settings($settings);
  $directives = SELECT * FROM vhost_directives WHERE parent=$vhost[['id']];
  foreach $directives as $directive {
    start_directive();
    $sub_settings = SELECT * FROM vhost_settings WHERE directive_id=$directive[['id']] ORDER by position;
    add_settings($sub_settings);
    end_directive();
  }
  end_vhost();

} </code>

Config result

<VirtualHost *:80>
<code>
  ServerName schiffbauer.net
  DocumentRoot /home/htdocs/schiffbauer.net/
  <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^/logs[[/]]*$ /cgi-bin/awstats.pl [[R]]
  </IfModule>

</VirtualHost> </code>

mschiff 11:47, 10 Jun 2005 (CEST)

apachevhosts.txt · Last modified: 2012/01/14 03:51 by 0.0.0.0