Apache HTTP Server – Command Reference Table (with Examples)

1. Service Management (Start/Stop/Restart)

CommandDescriptionExampleOutput/Usage
systemctl start httpdStarts the Apache servicesudo systemctl start httpdStarts Apache web server
systemctl stop httpdStops the Apache servicesudo systemctl stop httpdShuts down Apache
systemctl restart httpdRestarts Apache servicesudo systemctl restart httpdApplies config changes
systemctl reload httpdReloads Apache config without downtimesudo systemctl reload httpdGraceful reload
systemctl status httpdShows status of Apachesudo systemctl status httpdRunning/Failed info
systemctl enable httpdEnable Apache to start on bootsudo systemctl enable httpdAuto-start at boot
systemctl disable httpdDisable Apache at bootsudo systemctl disable httpdStop auto-start
apachectl gracefulGracefully restarts Apachesudo apachectl gracefulNo connection drop
apachectl restartRestart Apachesudo apachectl restartFull restart
apachectl stopStop Apachesudo apachectl stopHard stop
Command NameDescriptionExample
systemctl start apache2Starts the Apache service on Debian/Ubuntu (Systemd).sudo systemctl start apache2
systemctl start httpdStarts the Apache service on CentOS/RHEL (Systemd).sudo systemctl start httpd
service apache2 startStarts the Apache service on Debian/Ubuntu (SysVinit).sudo service apache2 start
service httpd startStarts the Apache service on CentOS/RHEL (SysVinit).sudo service httpd start
systemctl enable apache2Enables Apache to start automatically at boot on Debian/Ubuntu (Systemd).sudo systemctl enable apache2
systemctl enable httpdEnables Apache to start automatically at boot on CentOS/RHEL (Systemd).sudo systemctl enable httpd
chkconfig apache2 onEnables Apache to start at boot on Debian/Ubuntu (SysVinit).sudo chkconfig apache2 on
chkconfig httpd onEnables Apache to start at boot on CentOS/RHEL (SysVinit).sudo chkconfig httpd on
systemctl stop apache2Stops the Apache service on Debian/Ubuntu (Systemd).sudo systemctl stop apache2
systemctl stop httpdStops the Apache service on CentOS/RHEL (Systemd).sudo systemctl stop httpd
service apache2 stopStops the Apache service on Debian/Ubuntu (SysVinit).sudo service apache2 stop
service httpd stopStops the Apache service on CentOS/RHEL (SysVinit).sudo service httpd stop
systemctl restart apache2Restarts the Apache service (stops and starts) on Debian/Ubuntu (Systemd).sudo systemctl restart apache2
systemctl restart httpdRestarts the Apache service on CentOS/RHEL (Systemd).sudo systemctl restart httpd
service apache2 restartRestarts the Apache service on Debian/Ubuntu (SysVinit).sudo service apache2 restart
service httpd restartRestarts the Apache service on CentOS/RHEL (SysVinit).sudo service httpd restart
systemctl reload apache2Reloads Apache configuration without stopping the service (graceful restart) on Debian/Ubuntu.sudo systemctl reload apache2
systemctl reload httpdReloads Apache configuration on CentOS/RHEL.sudo systemctl reload httpd
service apache2 reloadReloads Apache configuration on Debian/Ubuntu (SysVinit).sudo service apache2 reload
service httpd reloadReloads Apache configuration on CentOS/RHEL (SysVinit).sudo service httpd reload
systemctl status apache2Checks the status of the Apache service on Debian/Ubuntu (Systemd).sudo systemctl status apache2
systemctl status httpdChecks the status of the Apache service on CentOS/RHEL (Systemd).sudo systemctl status httpd
service apache2 statusChecks the status of the Apache service on Debian/Ubuntu (SysVinit).sudo service apache2 status
service httpd statusChecks the status of the Apache service on CentOS/RHEL (SysVinit).sudo service httpd status

2. Configuration Checking

CommandDescriptionExampleOutput/Usage
apachectl configtestTest Apache config syntaxsudo apachectl configtestShows Syntax OK or errors
httpd -tAnother way to test configsudo httpd -tSyntax validation
httpd -SShow vhost configurationsudo httpd -SVHost layout and issues
apachectl -t -D DUMP_VHOSTSList all virtual hostssudo apachectl -t -D DUMP_VHOSTSHost/port mapping
apachectl -t -D DUMP_MODULESList all loaded modulessudo apachectl -t -D DUMP_MODULESActive modules
apachectl -t -D DUMP_RUN_CFGShow running configsudo apachectl -t -D DUMP_RUN_CFGRuntime configuration
Command NameDescriptionExample
httpd -d <serverroot>Sets the ServerRoot directory for configuration files.httpd -d /usr/local/apache2
httpd -f <config>Specifies a custom configuration file.httpd -f /etc/httpd/conf/custom.conf
httpd -C <directive>Processes a directive before reading config files.httpd -C "Include /etc/httpd/extra.conf"
httpd -c <directive>Processes a directive after reading config files.httpd -c "LogLevel debug"
httpd -D <parameter>Sets a parameter for use with <IfDefine> directives.httpd -D SSL
httpd -e <level>Sets LogLevel during startup for debugging.httpd -e debug
httpd -E <file>Sends startup error messages to a file.httpd -E /var/log/httpd/startup_errors.log
httpd -k startStarts the Apache server.httpd -k start
httpd -k restartRestarts the Apache server.httpd -k restart
httpd -k gracefulGracefully restarts Apache without closing connections.httpd -k graceful
httpd -k stopStops the Apache server.httpd -k stop
httpd -k graceful-stopGracefully stops Apache without closing connections.httpd -k graceful-stop
httpd -hDisplays a summary of command-line options.httpd -h
httpd -lLists modules compiled into the server.httpd -l
httpd -LLists all directives with their arguments and valid locations.httpd -L
httpd -SShows parsed virtual host settings from the configuration file.httpd -S
httpd -tTests configuration files for syntax errors.httpd -t
httpd -TTests configuration files without checking document roots.httpd -T
httpd -vPrints the Apache version and exits.httpd -v
httpd -VPrints the Apache version and build parameters, then exits.httpd -V
httpd -XRuns Apache in single-process debug mode (no forking).httpd -X
httpd -MLists all loaded modules (static and dynamic).httpd -M

3. Apache Files and Paths (Default)

File/PathDescriptionExample
/etc/httpd/conf/httpd.confMain Apache config fileConfigure ports, modules, logging
/etc/httpd/conf.d/Directory for custom .conf filesAdd vhosts here
/var/www/html/Default document rootStore website files here
/etc/httpd/logs/ or /var/log/httpd/Log directoryAccess and error logs
Command NameDescriptionExample
apachectl startStarts the Apache HTTP daemon. Errors if already running.sudo apachectl start
apachectl stopStops the Apache HTTP daemon.sudo apachectl stop
apachectl restartRestarts the Apache daemon (stops and starts, checks configuration).sudo apachectl restart
apachectl gracefulGracefully restarts Apache without aborting open connections.sudo apachectl graceful
apachectl graceful-stopGracefully stops Apache without aborting open connections.sudo apachectl graceful-stop
apachectl configtestTests configuration files for syntax errors without starting the server.sudo apachectl configtest
apachectl statusDisplays a full status report using mod_status (requires text-based browser like lynx).sudo apachectl status
apachectl fullstatusSimilar to status, provides detailed server status (requires mod_status).sudo apachectl fullstatus

4. Manual Testing Commands

CommandDescriptionExampleUse
curl http://localhostTest if Apache is serving pagescurl http://localhostGet default page
`netstat -tulnpgrep :80`Check if port 80 is open`sudo netstat -tulnp
`ss -tulngrep :80`Alternative to netstat`sudo ss -tuln
`ps auxgrep httpd`Check running Apache processes`ps aux

5. Installation Commands

CommandDescriptionExample
yum install httpdInstall Apache (CentOS/RHEL)sudo yum install httpd -y
apt install apache2Install Apache (Debian/Ubuntu)sudo apt install apache2 -y
dnf install httpdFedora/RHEL 8+ installationsudo dnf install httpd -y

6. Log Management

Log FileDescriptionExample
/var/log/httpd/access_logTracks all access requestssudo tail -f /var/log/httpd/access_log
/var/log/httpd/error_logLogs errorssudo tail -f /var/log/httpd/error_log
journalctl -u httpdView Apache logs via systemdsudo journalctl -u httpd

7. Module Management

CommandDescriptionExample
a2enmod <module>Enable module (Debian/Ubuntu)sudo a2enmod rewrite
a2dismod <module>Disable modulesudo a2dismod autoindex
apachectl -MShow loaded modulessudo apachectl -M
Command NameDescriptionExample
a2enmod <module>Enables a specific Apache module by creating a symlink in mods-enabled.sudo a2enmod rewrite
a2dismod <module>Disables a specific Apache module by removing the symlink from mods-enabled.sudo a2dismod proxy_http2

8. Virtual Host Configuration (Sample Format)

<VirtualHost *:80>
    ServerName www.example.com
    DocumentRoot /var/www/example
    ErrorLog /var/log/httpd/example_error.log
    CustomLog /var/log/httpd/example_access.log combined
</VirtualHost>

Enable with:

sudo systemctl reload httpd

9. Reload Without Downtime

CommandDescriptionExample
apachectl gracefulReload config without killing connectionssudo apachectl graceful

Summary Table: Most Used Apache Commands

PurposeCommandExample
Start Apachesystemctl start httpdsudo systemctl start httpd
Test Configapachectl configtestsudo apachectl configtest
Restart Apacheapachectl restartsudo apachectl restart
Check Virtual Hostsapachectl -Ssudo apachectl -S
View Logsjournalctl -u httpdsudo journalctl -u httpd
Enable Auto-startsystemctl enable httpdsudo systemctl enable httpd
Install Apacheapt install apache2sudo apt install apache2
Check Modulesapachectl -Msudo apachectl -M

Leave a Comment