a2query
Check if Apache module is enabled
TLDR
List enabled Apache modules
Check if a specific module is installed
List enabled virtual hosts
Display the currently enabled Multi Processing Module
Display Apache version
SYNOPSIS
a2query [-q] <type> [<name>]
where <type> is module, site, vhost, conf, or env
PARAMETERS
-q
Query mode: print status ('enabled', 'disabled', or absent) for <name> instead of listing all
module
Operate on modules (lists enabled if no name, queries status with -q)
site
Operate on sites (lists enabled sites if no name)
vhost
Operate on virtual hosts (similar to sites)
conf
Operate on configuration snippets in conf-enabled
env
Operate on environment variables in envvars.d
<name>
Specific item to query or filter list (basename without .load/.conf)
DESCRIPTION
The a2query command is a utility script in Debian-based distributions for querying the status of Apache2 configuration components, such as modules, sites, virtual hosts, configuration files, and environment variables. It interacts with the symlinked directory structure under /etc/apache2/, like mods-enabled/, sites-enabled/, etc.
Without arguments, specifying a type (e.g., module) lists all enabled items of that type. Providing a name queries or lists specifics. In query mode (-q), it outputs the status: 'enabled', 'disabled', or indicates absence. Exit codes reflect status: 0 for enabled, 1 for disabled, 2 for not found.
This tool is essential for scripting Apache management, checking prerequisites before enabling features, or verifying configurations. It assumes the standard Debian Apache2 layout and reads symlinks directly, making it lightweight and non-root friendly if paths are readable.
CAVEATS
Requires Debian-style Apache2 config (/etc/apache2/*-enabled). Does not reload Apache or modify configs. Non-root access needs read perms on config dirs.
EXAMPLES
a2query module rewrite → lists or checks rewrite module
a2query -q module rewrite → 'enabled' (exit 0)
a2query -q site 000-default → status of default site
EXIT CODES
0: enabled
1: disabled
2: not found
3+: error
HISTORY
Developed by Debian Apache packagers around 2004-2005 with the introduction of mods/sites-available/enabled symlink system for easier management. Evolved with Apache2.4 support.


