Skip to content

Instantly share code, notes, and snippets.

@HansCz
Created April 13, 2012 11:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HansCz/2376079 to your computer and use it in GitHub Desktop.
Save HansCz/2376079 to your computer and use it in GitHub Desktop.
Apache (Bash) - List apache2 virtualhosts
# List apache2 virtualhosts
# Lists virtualhosts currently enabled for apache2,
# showing the ServerName:port, conf file and DocumentRoot
/usr/sbin/apache2ctl -S 2>&1 | perl -ne 'm@.*port\s+([0-9]+)\s+\w+\s+(\S+)\s+\((.+):.*@ && do { print "$2:$1\n\t$3\n"; $root = qx{grep DocumentRoot $3}; $root =~ s/^\s+//; print "\t$root\n" };'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment