How to Start, Stop, or Restart Apache.

How To Start, Stop, Or Restart Apache.

This article explains how to start, stop, and restart Apache on the most popular 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.

 

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.