How to Start, Stop and Restart Apache Web Server in Linux

  1. Start, Stop and Restart Apache on Ubuntu and Debian Based Distributions
  2. Start, Stop and Restart Apache on Red Hat Based Distributions

Apache is one of the most popular open-source web server applications that interface between client and server. The Apache is responsible for efficient and secure HTTP communication between the client and the server.

Starting, stopping, and restarting are the most widely used operations used for Apache Web Server. We can use start, stop, and restart commands to start, stop and restart the Apache web server in Linux, respectively.

The commands to start, stop and restart Apache vary based on the Linux distribution we are using. We must ensure that we are logged in as root user to start, stop, and restart the Apache Web server.

Start, Stop and Restart Apache on Ubuntu and Debian Based Distributions

SystemD is used as the default service manager in most of the latest Linux OS versions, while the older versions use SysVinit as the default service manager. In Ubuntu and Debian based distribution, Apache service is referred to as apache2.

To start the Apache webserver service, we use the command:

sudo systemctl start apache2

To stop the Apache webserver service, we use the command:

sudo systemctl stop apache2

Whenever we make any changes to Apache’s web server configuration, we need to restart the Apache service. To restart the service, we use the command:

sudo systemctl restart apache2

To start the Apache webserver service in older versions using init.d scripts, we use the command:

sudo service apache2 start 

To stop the Apache webserver service in older versions, we use the command:

sudo service apache2 stop

To restart the Apache service in older versions, we use the command:

sudo service apache2 restart 

Start, Stop and Restart Apache on Red Hat Based Distributions

SystemD is the service manager for newer Red-Hat based distributions (RHEL and CentOS 7 and later versions). Similarly, for Red Hat distributions, Apache service is referred to as httpd.

To start the Apache webserver service, we use the command:

sudo systemctl start httpd

To stop the Apache webserver service, we use the command:

sudo systemctl stop httpd

Whenever we make any changes to Apache’s web server configuration, we need to restart the Apache service. To restart the service, we use the command:

sudo systemctl restart httpd

To start the Apache webserver service in older versions, we use the command:

sudo service httpd start 

To stop the Apache webserver service in older versions, we use the command:

sudo service httpd stop

To restart the Apache service in older versions, we use the command:

sudo service httpd restart 
comments powered by Disqus