How to Start, Stop, or Restart Apache

Updated on

3 min read

Start, Stop, Restart Apache

Apache is an open-source and cross-platform HTTP server. It comes loaded with powerful features and can be further extended with a wide variety of modules.

If you are a developer or system administrator, the chances are that you’re dealing with Apache on a regular basis.

Starting, stopping, and restarting/reloading are the most common tasks when working with an Apache webserver. The commands for managing the Apache service are different across Linux distributions.

Most of the recent Linux distributions are using SystemD as the default init system and service manager. Older distributions are based on SysVinit and using init scripts to manage services. Another difference is the name of the service. In Ubuntu and Debian, the Apache service is named apache2, while in Red Hat based system such as CentOS, the name of the service is httpd.

This article explains how to start, stop, and restart Apache on the most popular Linux distributions.

Before You Begin

The instructions assume that you are logged in as root or user with sudo privileges.

Both SystemD service units and SysVinit script takes the following arguments to manage the Apache service:

  • start: Starts the Apache service.
  • stop: Terminates the Apache service.
  • restart: Stops and then starts the Apache service.
  • reload: Gracefully restarts the Apache service. On reload, the main Apache process shuts down the child processes, loads the new configuration, and starts new child processes.
  • status: Shows the service status.

Start, Stop and Restart Apache on Ubuntu and Debian

SystemD is a system and service manager for the latest Ubuntu (20.04 18.04 ) and Debian (10 , 9 ) releases.

To start the Apache service, execute the following command:

sudo systemctl start apache2

To stop the Apache service, execute the following command:

sudo systemctl stop apache2

Whenever you make changes to the Apache configuration, you need to restart the server processes. To restart the Apache service, run:

sudo systemctl restart apache2

Older (EOLed) versions of Ubuntu or Debian are using init.d scripts to start, stop and restart the Apache daemon:

sudo service apache2 startsudo service apache2 stopsudo service apache2 restart

Start, Stop and Restart Apache on RHEL/CentOS

Systemd is the system and service manager for RHEL/CentOS 7 and 8 .

Start the Apache service:

sudo systemctl start httpd

Stop the Apache service:

sudo systemctl stop httpd

Restart the Apache service:

sudo systemctl restart httpd

If you have CentOS 6 or earlier system that uses SysV, use the following commands to start, stop and restart the Apache daemon:

sudo service httpd startsudo service httpd stopsudo service httpd restart

Conclusion

We have shown you how to start, stop, and restart the Apache webserver on various Linux systems.

If you have any questions or feedback, feel free to comment below.