Table of Contents

List all Hosts

Sometimes you will need to get a list of all hosts/domain/sub-domains your apache server is configured to serve. Here is a quick and easy way that lists all ServerName and ServerAlias entries in your configs:

blogs:/# cd /etc/apache2/sites-enabled/
blogs:/etc/apache2/sites-enabled# THECONFS="`ls`"; for ACONF in ${THECONFS}; do cat ${ACONF} | tr '\t' ' ' | grep -E '^ *(ServerName|ServerAlias)' | sed -r 's/^( |ServerName|ServerAlias)+//g' | tr ' ' '\n'; done | sort -fu
/var/customers/webs/cw01/wiki/data/pages/apache2/list_all_hosts.txt · Last modified: 2014/01/08 15:03 by wadmin
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki