Skip to main content
Version: 3.1.X

Virtual Host Test (Apache)

Problem: After modifying configuration files (httpd.conf, httpd-vhosts.conf) or adding a new Virtual Host, the Apache webserver often fails to start without providing clear error messages in the GUI.

This guide provides command-line techniques to verify the syntax and configuration.

Test Scenario

Open a terminal window:

  • Linux: Terminal / Bash
  • Windows: CMD (Command Prompt) or PowerShell

Linux

You can execute these commands regardless of whether the service is currently running.

# Quick syntax test (Shows "Syntax OK" or specific errors)
/opt/lampp/bin/httpd -t

# Show parsed variables & Virtual Host settings
/opt/lampp/bin/httpd -S

# Alternative using apachectl (Service must be stopped for full output sometimes)
sudo /opt/lampp/bin/apachectl -S

Windows (XAMPP)

Assuming XAMPP is installed in c:\xampp.

REM Quick syntax test
c:\xampp\apache\bin\httpd -t

REM Show variables & Virtual Host settings
c:\xampp\apache\bin\httpd -S

Windows (Cygwin)

If you are running ABCD via a Cygwin environment:

/cygdrive/c/abcd/www/cgi-bin/ansi/httpd -t
/cygdrive/c/abcd/www/cgi-bin/ansi/httpd -S


Reference: HTTPD Command Line Options

Common options for httpd (Apache Hypertext Transfer Protocol Server):

OptionDescription
-tRun syntax check for config files. Essential before restarting.
-SShow parsed Virtual Host settings (Synonym for -t -D DUMP_VHOSTS).
-vShow version number.
-MShow all loaded modules (Static and Shared).
-lList compiled-in modules.
-XDebug mode (only one worker, do not detach).
**`-k startrestart
-D nameDefine a name for use in <IfDefine name> directives.
-f fileSpecify an alternate ServerConfigFile.

Windows Specific Options

OptionDescription
-n nameSet service name and use its ServerConfigFile.
-k installInstall Apache as a Service (NT/Windows).
-k uninstallUninstall the Apache Service.