Short Tip: Check configured virtual hosts in Apache

Whenever you have to debug virtual host setups in Apache, checking the actual running virtual host configuration is a good first step. This can be done with the -S option used on the Apache binary: It lists all running virtual hosts and performs a syntax check.

On Fedora, RHEL, CentOS the Apache binary can be found on /usr/sbin/httpd:

# /usr/sbin/httpd -S
VirtualHost configuration:                                                (/etc/httpd/conf.d/me.conf:5) (/etc/httpd/conf.d/others.conf:1) (/etc/httpd/conf.d/others.conf:38)
Syntax OK

On Debian systems the call is almost the same, you just have to source the environment variables upfront, and the binary has a different name for historical reasons:

# source /etc/apache2/envvars
# /usr/sbin/apache2 -S
VirtualHost configuration:                                                (/etc/apache2/sites-enabled/me.conf:5) (/etc/apache2/sites-enabled/others.conf:1) (/etc/apache2/sites-enabled/others.conf:38)
Syntax OK

you might run into an error about user names, in such cases it is helpful to call upfront.

8 thoughts on “Short Tip: Check configured virtual hosts in Apache”

  1. I still somebody “here”?
    I have an issue with my virtual hosts:
    if I activate this statment in my httpd.conf

    Include conf/extra/httpd-fresas.conf

    where httpd-fresas.conf has this:

    DocumentRoot “/xampp/htdocs/fresas”
    ErrorLog “logs/”
    CustomLog “logs/” combined

    the server does not start

    but I add these same statments directly in the conf/extra/httpd-vhosts.conf
    the server start fine!
    why am i having this issue?

    I was originaly thinking in a statment like this:
    IncludeOptional conf/sites/*.conf
    to put all my virtual host configurations in the conf/sites directory,
    to have a more easy administration of them, but…

    1. Hi Juan,
      thanks for reaching out. But it is hard to help in a blog post comment section. How about you post the issue in or similar and see if you can get help there? You can also post the link to the issue here and I am happy to help in a forum where it is way easier to troubleshoot something.
      In general I would first check out the logs: they might directly tell you what is going on. If they don’t, post them as part of your issue as well.
      Hope that helps!

    2. Juan,

      See :

      The value of the ServerAlias directive is supposed to be a list of host names inclusive-or domain names, not URIs, in this case URLs. In this case, the value of the ServerAlias directive should be “” instead of “”. URIs include both URNs and URLs, not only URLs. I follow the practice of Tim Berners-Lee (TimBL), the creator of the World Wide Web, to use the more general term “URI” unless it is necessary to distinguish between the two specific types of URIs but the common/popular usage is to use the specific term “URL”.


  2. Thank you very much for your support!
    It seems that I just had one directory missing!! (I create it with a misspelling) after I fixed that all is working fine now! (Brolin, the ServerAlias was ok, but the process “here” changed it to include the http://…).
    is there a way to say “solved” and then close it?
    Also I’m sorry for my delay to answer you, I was working in other stuff!

    1. Hi Juan, thanks for letting us know that this helped. That is really nice, even after such a long time!
      Glad that it is now solved, others will realize that by reading the comments.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: