Apache is cross-platform and open-source Web server. It is part of the popular LAMP (Linux, Apache, MySQL, PHP) stack of software. This guide will show you how to start, stop, and restart Apache service on Linux systems.
It comes loaded with powerful features and can be further extended with a wide variety of modules. The Apache service managing are different across Linux distributions.
Currently, the latest Linux distributions are using SystemD as the default init system and service manager. So based on this Apache service can be manage and also the name of the service are different across the distributions. For example, in Ubuntu and Debian, the Apache service name is apache2
while in Red Hat based system like CentOS, the Apache service name is httpd
.
Prerequisite
Make sure you are logged in as root or user with sudo privileges.
The SystemD service units 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
On latest Ubuntu 20.04, 18.04, 16.04 and Debian 10, 9 ships with SystemD as system and service manager.
To start the Apache service run the below command:
sudo systemctl start apache2
Execute the following command to stop the Apache service:
sudo systemctl stop apache2
When you do any changes to the Apache configuration, you need to restart the server processes. Run the following command to restart the Apache service:
sudo systemctl restart apache2
Start, Stop and Restart Apache on RHEL/CentOS
Also, on RHEL/CentOS 7 and 8 Systemd is the system and service manager.
Start the Apache service:
sudo systemctl start httpd
Stop the Apache service:
sudo systemctl stop httpd
Restart the Apache service:
sudo systemctl restart httpd
Conclusion
In this article, we show you how to start, stop, and restart Apache service on various Linux systems.
If you have any questions or suggestion, please leave a comment below.