How to Start, Stop, Restart Apache Server

Starting, stopping and restarting Apache servers are the most common tasks faced by developers and system administrators.

The commands for managing the Apache service vary for different Linux distributions. Most modern Linux distributions use the SystemD system and service manager. Older distributions are based on SysVinit and use init scripts to manage services. Another important difference is the name of the service. On Ubuntu and Debian, the Apache service is called apache2, and on Red Hat-based systems such as CentOS, the service is called httpd.

In this article we will take a detailed look at how to start, stop or restart the Apache server in the most popular distributions.

Start, Stop, Restart Apache Server

How to Start, Stop, Restart Apache Server on Ubuntu and Debian

To start Apache on Ubuntu and Debian run the command:

sudo systemctl start apache2

To stop the Apache on Ubuntu and Debian service use the command:

sudo systemctl stop apache2

To restart Apache, use the command:

sudo systemctl restart apache2

Older (EOLed) versions of Ubuntu and Debian use init.d scripts to start, stop and restart Apache:

sudo service apache2 start

sudo service apache2 stop

sudo service apache2 restart

How to Start, Stop, Restart Apache Server on RHEL/CentOS

To start Apache use the command:

sudo systemctl start httpd

To stop Apache, run the command:

sudo systemctl stop httpd

To restart Apache, use the command:

sudo systemctl restart httpd

If your server is running CentOS 6 or earlier, use the following commands to start, stop, and restart Apache:

sudo service httpd start

sudo service httpd stop

sudo service httpd restart

How to Start, Stop, Restart Apache Server on Fedora

To start Apache use the command:

systemctl start httpd

To stop Apache:

systemctl stop httpd

To restart:

apachectl -k restart

|

Leave a Reply