**DRAFT** ===== Table Definitions ===== - vhost_directives (for apache definitions per vhost) * id(int) * parent(int) * directive(varchar) * value(varchar) - vhost_settings (for apache "Key Value" definitions per vhost) * id(int) * directive_id(int) * position(int) * key(varchar) * value(varchar) - 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" |+vhost_directives |- ! id !! parent !! directive !! value |- | 1 || NULL || VirtualHost || *:80 |- | 2 || 1 || IfModule || mod_rewrite.c |} {| border="1" cellpadding="2" |+vhost_settings !id !! directive_id !! key !! position !! value |- |1 || 1 || ServerName || 1 || schiffbauer.net |- |2 || 1 || DocumentRoot || 2 || /home/htdocs/schiffbauer.net/ |- |3 || 2 || RewriteEngine || 1 || On |- |4 || 2 || RewriteRule || 2 || ^/logs[[/]]*$ /cgi-bin/awstats.pl [[R]] |} ===== Pseudo code ===== vhost generation: $vhosts = SELECT * FROM vhost_directives WHERE directive="VirtualHost"; foreach $vhosts as $vhost { 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(); } ===== Config result ===== ServerName schiffbauer.net DocumentRoot /home/htdocs/schiffbauer.net/ RewriteEngine On RewriteRule ^/logs[[/]]*$ /cgi-bin/awstats.pl [[R]] --[[User:Mschiff|mschiff]] 11:47, 10 Jun 2005 (CEST)