apachectl
Control the Apache HTTP server
TLDR
Start the server
Restart the server
Stop the server
Test configuration file validity
Check server status (requires the lynx browser)
Reload configuration without dropping connections
Print full Apache configuration (not always supported)
Display help
SYNOPSIS
apachectl [command] [httpd-switches]
PARAMETERS
-C "directive"
Process directive before reading config files
-c "directive"
Process directive after reading config files
-D name
Set environment variable
-d directory
Specify initial ServerRoot directory
-f file
Specify configuration file
-k command
Run control command: start|stop|restart|graceful|graceful-stop|reload|status|fullstatus|configtest|test
-l
List compiled-in modules
-L
List available configuration directives
-S
List virtual hosts & configuration
-t
Syntax check configuration files
-T
Full table syntax check
-v
Show Apache version
-V
Show compile settings
-X
Debug mode (single-process)
-h
Show help
DESCRIPTION
apachectl is a front-end script for controlling the Apache HTTP Server (httpd). It simplifies common administrative tasks such as starting, stopping, restarting, and testing the configuration of the Apache web server daemon. Designed for ease of use, it wraps the underlying httpd binary, passing options and commands transparently while handling environment setup like loading Apache modules and configuration files.
Primarily used on Unix-like systems, apachectl reads the main server configuration file (usually httpd.conf or apache2.conf) and supports actions like syntax checks before restarts to prevent downtime from errors. It's invoked with commands like start, stop, restart, or graceful for reloads without dropping connections. Options mirror those of httpd, allowing fine-tuned control over directories, files, and directives.
On modern distributions using systemd (e.g., Ubuntu, CentOS), it's often superseded by systemctl for service management, but remains essential for config testing and legacy setups. Running as root is typical for server control, emphasizing secure permissions.
CAVEATS
Requires root privileges for most commands; use sudo. On systemd systems, prefer systemctl for start/stop. Configtest (-t) advised before restart to avoid downtime.
COMMON COMMANDS
start: Start httpd daemon
stop: Stop gracefully
restart: Stop then start
graceful: Restart handling current connections
configtest or -t: Test config syntax
FILES
SYSCONFDIR/httpd.conf (main config)
SERVERBIN/httpd (binary)
Environment from apachectl script
HISTORY
Introduced in Apache 1.3 (1998) as a convenience script; evolved with Apache 2.0+ for modularity and 2.4 for better systemd integration. Widely used in traditional init systems.
SEE ALSO
httpd(8), apache2ctl(8), systemctl(1)


