Skip to content

Instantly share code, notes, and snippets.

@benclark
Created October 4, 2012 21:14
Show Gist options
  • Save benclark/3836503 to your computer and use it in GitHub Desktop.
Save benclark/3836503 to your computer and use it in GitHub Desktop.
Lighttpd vhosts config script
#!/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
}
@benclark
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment