Apache

Find all ServerNames and ServerAliases in several vhosts.conf files

(Last Updated On: 12 April, 2018)

In Apache one specify the servername and serveralias in a virtualhost directive in possible a single .conf file.

We had an Apache webserver with hundreds of such .conf files. With this bash one-liner you can find all ServerName and ServerAlias’s:

cd /etc/httpd/vhosts.d/ ; find . -type f | xargs egrep -i 'servername|serveralias' | awk {'print $3'} | sort | uniq

Leave a Reply

Your email address will not be published. Required fields are marked *