Apache HTTP Server is the most popular web server in the world. Apache is a free, open source, and cross-platform HTTP server that provides powerful features that can be expanded using a variety of modules.
If you are a developer or system administrator, you probably deal with Apache on a regular basis.
Starting, stopping, and reloading / reloading are among the most common tasks when working with Apache web server. The Apache Services Manager commands are slightly different across Linux distributions.
Most modern Linux distributions use SystemD as the default service and init system. Legacy distributions are based on SysVinit and use raw scripts to manage services. Another difference is the name of the service. In Ubuntu and Debian, the service is named Apache
apache2, Whereas on Red Hat-based systems like CentOS, the service name is
Usually if you are used to using a Debian / ubuntu based server, you will feel a little confused if you are using RHEL / CentOS. In this guide, we will explain how to start, stop, and restart Apache on the most popular Linux distributions.
These instructions can only be executed as a root user or a user with sudo privileges.
The SystemD server and the SysVinit script take the following arguments to manage Apache services:
- Start: Start the Apache Service (which was previously stopped).
- Stop: Apache service stopped.
- Re-start: Force stop and start the Apache service.
- Reloading: Like restarting, but this command will make the Apache service stop and start safely, start to stop Dependent operations, Download the new configuration, and start Dependent operations New, thus avoiding corruption / non-synchronization of the input data with the database.
- Status: Indicates the status of the service.
How to start, stop, and restart Apache on Ubuntu and Debian
SystemD is a System and Service Manager for the latest Ubuntu (18.04, 16.04) and Debian (10, 9) releases.
Run the following command for Start Apache Service:
sudo systemctl start apache2
Run the following command for Stop Apache Service:
sudo systemctl stop apache2
Every time you make changes to Apache configuration, you must restart the server process. Run the following command to restart the Apache service:
sudo systemctl restart apache2
Older versions of Ubuntu or Debian (which are actually EOL) use the init.d script to start, stop, and restart the Apache daemon:
sudo service apache2 start sudo service apache2 stop sudo service apache2 restart
Start, stop, and restart Apache on RHEL / CentOS
Systemd is the System and Services Manager for RHEL / CentOS 7 and 8. Systemd is the Systems and Services Manager for RHEL / CentOS 7 and CentOS 8.
Start the Apache service:
sudo systemctl start httpd
Stop Apache Service:
sudo systemctl stop httpd
Restart the Apache service:
sudo systemctl restart httpd
If you have CentOS 6 (or earlier), use the following command to start, stop, or restart the Apache daemon:
sudo service httpd start sudo service httpd stop sudo service httpd restart
In this guide, we showed you how to start, stop, and restart Apache web server on various Linux systems.