Información sobre apache desde línea de comandos

Siguiendo el hilo de la Información sobre PHP desde línea de comandos hoy vamos a ver las posibilidades que nos ofrece el servidor web Apache en la línea de comandos:

En primera instancia revisamos si el binario httpd se encuentra en nuestro path o si debemos llamar a su ruta completa:

# whereis httpd
httpd: /usr/sbin/httpd /etc/httpd

En este caso podemos llamarlo directamente con «httpd», vamos a ver algunas opciones que nos permiten sacar información sobre el servidor web:

Mostrar la versión de Apache:

# httpd -v
# httpd -v
Server version: Apache/X.X.XX
Server built:   Sep 21 2009 09:57:47

Mostrar información y ajustes de la compilación:

Como véis también muestra la información que sacábamos con httpd -v:

# httpd -V
Server version: Apache/X.X.XX
Server built:   Sep 21 2009 09:57:47
Server's Module Magic Number: ...
Server loaded: ...
Compiled using:  ...
Architecture:   32-bit
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAS_SENDFILE
...
...

Mostrar módulos compilados:

# httpd -l
Compiled in modules:
  core.c
  mod_access.c
  mod_auth.c
  mod_include.c
  mod_log_config.c
  mod_logio.c
  mod_env.c
  mod_expires.c
...
...

Ejecutar una revisión de sintaxis para los ficheros de configuración:

# httpd -t
Syntax OK

Listar las directivas de configuración disponibles:

# httpd -L
Directory (core.c)
	Container for directives affecting resources located in the specified directories
	Allowed in *.conf only outside...
	Container for directives affecting resources accessed through the specified URL paths
	Allowed in *.conf only outside ...
VirtualHost (core.c)
	Container to map directives to a particular virtual host, takes one or more host addresses
	Allowed in *.conf only outside ..
Files (core.c)
...
...

Especificar un fichero de configuración alternativo:

# httpd -f fichero

Especificar un ServerRoot alternativo:

# httpd -d directorio

Listar las opciones en línea de comandos:

# httpd -h
Usage: /usr/local/apache/bin/httpd [-D name] [-d directory] [-f file]
                                   [-C "directive"] [-c "directive"]
                                   [-k start|restart|graceful|stop]
                                   [-v] [-V] [-h] [-l] [-L] [-G] [-t] [-S]
Options:
  -D name           : define a name for use in  directives
  -d directory      : specify an alternate initial ServerRoot
  -f file           : specify an alternate ServerConfigFile
  -C "directive"    : process directive before reading config files
  -c "directive"    : process directive after reading config files
  -e level          : show startup errors of level (see LogLevel)
  -E file           : log startup errors to file
  -v                : show version number
  -V                : show compile settings
  -h                : list available command line options (this page)
  -l                : list compiled in modules
  -L                : list available configuration directives
  -G                : list available configuration directives after loading conf file
  -t -D DUMP_VHOSTS : show parsed settings (currently only vhost settings)
  -S                : a synonym for -t -D DUMP_VHOSTS
  -t                : run syntax check for config files