User Tools

Site Tools


js#vista.png msort nsort


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
apache2/list_all_hosts.txt · Last modified: 2020/02/24 11:16 (external edit)