How to use the command 'a2query' (with examples)

How to use the command 'a2query' (with examples)

The ‘a2query’ command is used to retrieve runtime configuration from Apache on Debian-based operating systems. It provides information about enabled Apache modules, virtual hosts, the Multi Processing Module, and the Apache version.

Use case 1: List enabled Apache modules

Code:

sudo a2query -m

Motivation: This use case is useful when you need to quickly identify which modules are currently enabled in your Apache configuration.

Explanation:

  • ‘sudo’: Runs the command with root privileges.
  • ‘a2query’: The command itself.
  • ‘-m’: Specifies the option to retrieve a list of enabled Apache modules.

Example output:

ssl
rewrite
php7.4

Use case 2: Check if a specific module is installed

Code:

sudo a2query -m module_name

Motivation: This use case allows you to check whether a specific Apache module is installed and enabled in your configuration.

Explanation:

  • ‘sudo’: Runs the command with root privileges.
  • ‘a2query’: The command itself.
  • ‘-m’: Specifies the option to retrieve a list of enabled Apache modules.
  • ‘module_name’: The name of the module you want to check.

Example output:

If the module ‘ssl’ is installed and enabled:

ssl

If the module ‘foo’ is not installed or enabled:

Module 'foo' is not enabled.

Use case 3: List enabled virtual hosts

Code:

sudo a2query -s

Motivation: This use case allows you to quickly view a list of enabled virtual hosts in your Apache configuration.

Explanation:

  • ‘sudo’: Runs the command with root privileges.
  • ‘a2query’: The command itself.
  • ‘-s’: Specifies the option to retrieve a list of enabled virtual hosts.

Example output:

example.com
subdomain.example.com

Use case 4: Display the currently enabled Multi Processing Module

Code:

sudo a2query -M

Motivation: This use case provides information about the currently enabled Multi Processing Module (MPM), which can be useful for troubleshooting or optimization purposes.

Explanation:

  • ‘sudo’: Runs the command with root privileges.
  • ‘a2query’: The command itself.
  • ‘-M’: Specifies the option to retrieve the currently enabled Multi Processing Module.

Example output:

event

Use case 5: Display the Apache version

Code:

sudo a2query -v

Motivation: This use case allows you to quickly check the version of Apache installed on your system.

Explanation:

  • ‘sudo’: Runs the command with root privileges.
  • ‘a2query’: The command itself.
  • ‘-v’: Specifies the option to retrieve the Apache version.

Example output:

Server version: Apache/2.4.41 (Ubuntu)
Server built:   2020-08-12T19:46:17

Conclusion

The ‘a2query’ command is a helpful tool for retrieving runtime configuration information from Apache on Debian-based operating systems. It provides various options to view enabled Apache modules, virtual hosts, the Multi Processing Module, and the Apache version. This can be valuable for troubleshooting, optimization, or general system information purposes.

Related Posts

How to use the command 'tmutil' (with examples)

How to use the command 'tmutil' (with examples)

The tmutil command is a utility for managing Time Machine backups on macOS.

Read More
How to use the command `watchlistd` (with examples)

How to use the command `watchlistd` (with examples)

The watchlistd command manages the Apple TV app’s watch list. It is not intended to be invoked manually and handles the functionality of the watch list in the background.

Read More
How to use the command 'odps table' (with examples)

How to use the command 'odps table' (with examples)

This article explains how to use the ‘odps table’ command in ODPS (Open Data Processing Service) with various use cases.

Read More