Get a list of all virtual hosts which are defined in all apache configuration files

Have you ever looked in the apache config files to see where a website’s virtual host is defined? The apache2ctl script has a useful option that could come in good here. When you execute the command, it should look like this:

apache2ctl -S

You’ll obtain a list of all virtual hosts and default servers in the shell, along with the line number where they’re declared. Example:

~# apache2ctl -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:8080                 is a NameVirtualHost
default server ispconfig.local (/etc/apache2/sites-enabled/000-ispconfig.vhost:10)
port 8080 namevhost ispconfig.local (/etc/apache2/sites-enabled/000-ispconfig.vhost:10)
*:8081                 is a NameVirtualHost
default server ispconfig.local (/etc/apache2/sites-enabled/000-apps.vhost:10)
port 8081 namevhost ispconfig.local (/etc/apache2/sites-enabled/000-apps.vhost:10)
*:80                   is a NameVirtualHost
default server ispconfig.local (/etc/apache2/sites-enabled/000-default:1)
port 80 namevhost ispconfig.local (/etc/apache2/sites-enabled/000-default:1)
port 80 namevhost example.com (/etc/apache2/sites-enabled/example.com.vhost:7)
Syntax OK
Sponsored

Thanks to Planetfox for this tip.

Sponsored

The post Get a list of all virtual hosts which are defined in all apache configuration files appeared first on FAQforge.

Ubuntu Server Admin

Recent Posts

A CISO’s preview of open source and cybersecurity trends in 2026 and beyond

Open source has come a long way. Recently I was watching a keynote address by…

7 hours ago

Canonical Kubernetes officially included in Sylva 1.5

Sylva 1.5 becomes the first release to include Kubernetes 1.32, bringing the latest open source…

7 hours ago

Canonical expands total coverage for Ubuntu LTS releases to 15 years with Legacy add-on

Expansion ensures business continuity without forcing major upgrades Today, Canonical announced the expansion of the…

1 day ago

Announcing YARD-Lint: Keep Your Ruby Documentation Solid

TL;DR: YARD-Lint catches documentation issues, just like RuboCop for code. Star it and use it…

1 day ago

Canonical releases FIPS-enabled Kubernetes

Deploy a FedRAMP-ready kubernetes cluster and application suite, with FIPS 140-3 crypto and DISA-STIG hardening…

3 days ago

Canonical announces optimized Ubuntu images for Google Cloud’s Axion N4A Virtual Machines

This new release brings the stability and security of Ubuntu to Axion-based N4A virtual machines…

3 days ago