The httpd.conf exploder!

Posted on November 30, 2006

I thought that it’d be easy to break up a httpd.conf file up into multiple files per VirtualHost using a single line of perl. Turns out, I was most mistaken. Here is the one loooong line of perl to perform the explosion.

perl -ne ' if (/<Virtualhost (\*:80|[0-9.:]+)>/ .. /< \/VirtualHost>/) { $data.=$_ }; if (/ServerName/) { chomp; $sn=$_; $sn=~s/\s*ServerName\s*([^\s]+)\s*/$1/; } if (/<\/VirtualHost>/) { open(outfile, “>>$sn.conf”); print outfile $data; close outfile; $data=”" } ‘ < httpd.conf

Trackbacks

Use this link to trackback from your own site.

Comments

Leave a response

  1. jtax Thu, 30 Nov 2006 19:11:42 MST

    you son of a beeswax!

  2. sobel Thu, 04 Jan 2007 18:34:20 MST

    I thought it would be easy, too. This clearly shows I was mistaken.

Comments