Apache is a free and open-source package that is used cross-platform as HTTP Server. It is a robust and most widely used web server and it also can be used as a proxy server. This article explains the basic part of Apache. We have seen how to start, stop, or restart Apache web server daemon on Linux distribution whether it’s an older or newer version.
Apache has lots of other modules that enhance its capabilities to handle web traffic. It’s very common among developers and system administrators as they require it most to host websites either in a development or production environment.
In this article, but if you are looking for Apache installation checkout another tutorial, we are going to look at how to do basic tasks with apache in which we look how to start, stop, and restart/reload when working with an Apache webserver. These start, stop, reload/restart commands are different as per the Linux distributions.
The latest distributions are using SystemD as service manager. Older Linux distributions are using init scripts to manage services. Apache daemon is represented differently in Ubuntu/Debian and Centos/RHEL. In CentOS/RHEL based OS its service name is httpd and In Ubuntu/Debian, the service is called apache2. We have to keep this in mind when running start, restart, stop commands.
In this article, we’ll see how to stop, start, and restart Apache Service Linux distributions.
You should have logged in as either root user or sudo privileged user.
Below arguments are common either its SystemD service manager or init script based as both will take below parameters to manage the apache service.
start: As to start the Apache service.
stop: It will kill the Apache processes.
reload: It Restart Apache service gracefully. On reload, any changes done in configuration updated.
restart: It’s first stops and starts the Apache service again.
status: It will shows the Apache service status.
How to manage Apache service Ubuntu/Debian
On ubuntu/Debian SystemD is the service manager on the latest Ubuntu Version (18.04, 16.04) and Debian (9, 10 ).
The below command will start the Apache service:
sudo systemctl start apache2
The below command will stop the Apache service:
sudo systemctl stop apache2
Whenever you make any configuration changes in Apache to make those changes live you have to restart the Apache service. Run the below command to restart the Apache service:
sudo systemctl restart apache2
Older versions of Ubuntu(14.04) or Debian(7, 8) uses init.d scripts to handle Apache service to start, stop and restart:
sudo service apache2 start sudo service apache2 stop sudo service apache2 restart
Start, Stop and Restart Apache on RHEL/CentOS
Same as Ubuntu and Debian Systemd is also manager of services in RHEL/CentOS 7 and 8.
To start the Apache service, Run the below command:
sudo systemctl start httpd
For stop the Apache service, Run the below command:
sudo systemctl stop httpd
To restart the Apache service, Run the below command:
sudo systemctl restart httpd
If you have an older version like CentOS 6 (or earlier) then you should use the below commands to start, stop and restart the Apache service:
sudo service httpd start sudo service httpd stop sudo service httpd restart
This article explains the basic part of Apache. We have seen how to start-stop or restart the apache web server Daemon on Linux distribution whether it’s an older or newer version.
If you have any doubts further comment below to reach out.