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]
apachectl [command] [arguments]
apachectl [option] [arguments]
PARAMETERS
start
Starts the Apache HTTP Server.
stop
Stops the Apache HTTP Server.
restart
Performs a full restart of the Apache HTTP Server. It stops and then starts the daemon, potentially causing a brief service interruption.
graceful
Performs a graceful restart. New requests are handled by the new server processes, while old processes are allowed to finish their current requests before exiting. This minimizes downtime.
graceful-stop
Initiates a graceful shutdown. New connections are refused, and existing connections are allowed to complete.
configtest
Checks the syntax of the Apache configuration files (httpd.conf) without starting or restarting the server. Essential for verifying configuration changes before applying them.
status
Displays a brief summary of the server's status. Requires mod_status to be enabled and configured, and a text-based browser like lynx or w3m.
fullstatus
Displays a detailed status report, including individual request information. Similar requirements to status.
help
Shows a summary of available apachectl commands.
version
Displays the Apache HTTP Server version information.
-V
Displays the httpd server's version and compile settings (similar to httpd -V).
-t
Performs a syntax test of the configuration files (equivalent to configtest).
-D DEFINE
Passes a define variable to the httpd server.
-f configfile
Specifies an alternative server configuration file to use instead of the default.
-C directive
Processes a configuration directive before reading the main configuration files.
-c directive
Processes a configuration directive after reading the main configuration files.
DESCRIPTION
apachectl is a front-end control script for the Apache HTTP Server (httpd daemon). It provides an easy-to-use command-line interface to manage common Apache operations, such as starting, stopping, restarting, and checking the configuration.
While it wraps calls to the underlying httpd binary, it often includes additional logic for environment setup, configuration file location, and error handling, making it more robust than directly invoking httpd commands. It is widely used in traditional init.d scripts and, in some setups, even by modern systemd service files to manage the Apache service lifecycle. Its primary purpose is to simplify server administration and ensure proper shutdown and startup sequences.
CAVEATS
Most apachectl operations that modify the server's state (start, stop, restart) require root privileges.
The status and fullstatus commands rely on the mod_status module being enabled and correctly configured in Apache's httpd.conf, along with the availability of a text-based web browser like lynx or w3m on the system.
On modern Linux distributions, systemctl is the preferred method for managing services. While apachectl still functions, systemctl start httpd (or apache2) is often the standard and recommended approach, as the systemd service unit may internally call apachectl or handle the daemon directly.
BEST PRACTICE: CONFIGURATION TESTING
Always run apachectl configtest (or apachectl -t) after making any changes to your Apache configuration files and before attempting a restart or graceful restart. This prevents the server from failing to start due to syntax errors, potentially causing downtime.
SYSTEMD INTEGRATION
On systems using systemd, you typically manage Apache via commands like systemctl start apache2 or systemctl restart httpd. The systemd service unit for Apache often includes directives that either call apachectl internally or handle the daemon directly. While apachectl can still be used for specific tasks (like configtest or detailed status checks), systemctl provides a more unified and robust service management experience across the OS.
HISTORY
apachectl has been an integral part of the Apache HTTP Server distribution since its early versions, serving as the primary administrative tool for managing the httpd daemon. It emerged to simplify the complex command-line arguments of httpd into more user-friendly actions (like 'start' and 'restart'). Before the widespread adoption of modern service managers like systemd, it was the standard way to integrate Apache into system init scripts (e.g., SysVinit /etc/init.d/apache2 files). Its core functionality has remained remarkably consistent over decades, evolving to support features like graceful restarts while maintaining backward compatibility.