Created
October 4, 2012 21:14
-
-
Save benclark/3836503 to your computer and use it in GitHub Desktop.
Lighttpd vhosts config script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -wl | |
use strict; | |
use File::Glob ':glob'; | |
my $sitesdir = shift || "/mnt/Sites/"; | |
sleep 1 while (!(chdir($sitesdir))); | |
my @sites = bsd_glob('*/{repo,trunk}'); | |
for my $site (@sites) { | |
my($repo_path, $site_name) = $site =~ m/((.+)\/.+)$/; | |
my $document_root = $sitesdir . $repo_path; | |
print <<LIGHTTPD; | |
\$HTTP["host"] =~ "^$site_name(:\\d+)?\$" { | |
server.document-root = "$document_root" | |
url.access-deny = ( | |
"~", ".inc", ".engine", ".install", ".module", ".info", ".sh", ".sql", | |
".theme", ".tpl.php", ".xtmpl", "Entries", "Repository", "Root" | |
) | |
url.rewrite-if-not-file = ( | |
"^/([^\\?]+)(\\?(.*))?" => "/index.php?q=\$1&\$3" | |
) | |
} | |
LIGHTTPD | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is actually not working very well. I'm having a timeout issue with the
$sitesdir
not existing at boot because in my VM it is a NFS share. I would very much like to get this working so I can distribute it as part of a vagrant VM.