How to verify configured virtual hosts in apache: apache2ctl – Apache HTTP Server Control Interface

Apache HTTP Server

Creating virtual host configurations on your Apache server does not magically cause DNS entries to be created for those host names. You must have the names in DNS, resolving to your IP address, or nobody else will be able to see your web site. Virtual hosts allow you to run multiple websites off of one web server as well as customize settings for each site.

You need to verify the configured and available virtual hosts whenever you are creating a new virtual host file or updating an existing virtual host file before restarting your Apache server. If any small issue found in the configured virtual host file then Apache couldn’t restart properly and Apache server will be down.

Command to verify all configured virtual hosts on your Apache server:

# apache2ctl -t

or

# /usr/sbin/apache2ctl -t

-t is the instruction argument to /usr/sbin/apache2ctl command to verify all available virtual hosts.

Successful response:

Syntax OK

Failure response:

Type 1: Failure due to wrong value configured

AH00112: Warning: DocumentRoot [/srv/www/testwebsite] does not exist
Syntax OK

Type 2: Failure due to wrong command used

AH00526: Syntax error on line 14 of /etc/apache2/sites-enabled/devwebsite.conf:
Invalid command 'DocumentRoot1', perhaps misspelled or defined by a module not included in the server configuration
Action '-t' failed.
The Apache error log may have more information.

If you found failure response, then fix it as a first step before restarting your Apache server to avoid disturbing your running website.

You Might Also Like

Leave a Reply

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