How to Start, Stop, and Restart Apache on Linux

Managing the Apache HTTP server is a fundamental skill for Linux system administrators and web developers. Whether you are applying configuration changes, troubleshooting errors, or performing routine system maintenance, you will frequently need to control the status of the web server. This guide provides the exact commands needed to start, stop, and restart the Apache service across major Linux distributions, including Ubuntu, Debian, CentOS, RHEL, and Fedora, using modern systemd commands as well as legacy init.d alternatives.

Managing Apache on Systemd Distributions

Modern Linux distributions—including Ubuntu 16.04 and later, Debian 8 and later, CentOS 7 and later, and all recent versions of RHEL and Fedora—use systemctl to manage system services.

Note: The name of the Apache service depends on your operating system. Ubuntu and Debian-based systems refer to it as apache2, while CentOS, RHEL, and Fedora refer to it as httpd.

For Ubuntu and Debian Systems

To start the Apache service if it is currently offline:

sudo systemctl start apache2

To stop the Apache service immediately:

sudo systemctl stop apache2

To completely restart the Apache service (this will kill all active connections and spin up the server again):

sudo systemctl restart apache2

If you have made configuration changes and want to apply them without dropping active user connections, use the reload command instead:

sudo systemctl reload apache2

To check the current running status of your Apache server:

sudo systemctl status apache2

For CentOS, RHEL, and Fedora Systems

To start the Apache service:

sudo systemctl start httpd

To stop the Apache service:

sudo systemctl stop httpd

To restart the Apache service entirely:

sudo systemctl restart httpd

To gracefully reload the configuration without severing active connections:

sudo systemctl reload httpd

To verify whether the Apache service is actively running:

sudo systemctl status httpd

Managing Apache on Older Linux Distributions

If you are working on an older legacy server that does not utilize systemd (such as Ubuntu 14.04 or CentOS 6 and older), you must use either the service wrapper command or call the init.d script directly.

Using the Service Command

The service command operates across most older platforms and automatically routes your instruction to the correct directory.

Using Init.d Scripts Direct Path

Alternatively, you can interact directly with the initialization scripts located inside the /etc/init.d/ directory.

Enabling Apache to Launch at Boot

Controlling the running state of the service does not dictate what happens when the physical or virtual machine reboots. If you want to ensure that Apache automatically starts up whenever your Linux machine turns on, you must enable the service.

To enable Apache to start automatically at system bootup:

If you want to reverse this decision and prevent Apache from starting automatically when the computer boots up: