Apache Command Reference
Essential Apache commands for managing modules, testing configuration, and controlling the server.
Module Management
# List all enabled/loaded modules (Debian/Ubuntu)
apache2ctl -M
a2query -m
# List all modules (CentOS/RHEL)
httpd -M
# Enable a module
sudo a2enmod rewrite
sudo a2enmod headers
sudo a2enmod ssl
# Disable a module
sudo a2dismod autoindex
# Enable/disable a site
sudo a2ensite example.com.conf
sudo a2dissite example.com.conf
# Enable/disable a config
sudo a2enconf php8.1-fpm
sudo a2disconf php8.1-fpm
Configuration Test
# Test config syntax
apachectl configtest
httpd -t -f /etc/httpd/conf/httpd.conf # CentOS
# Show virtual host configuration
apachectl -S # Debian/Ubuntu
httpd -S # CentOS
Service Management
# Start / stop / restart
sudo systemctl start apache2
sudo systemctl stop apache2
sudo systemctl restart apache2
# Graceful restart (waits for active connections)
sudo apachectl graceful
# Reload config without restart
sudo systemctl reload apache2