apache start stop restart

Start / Stop and Restart Apache 2 Web Server

How do I restart an Apache 2 Web Server under a Debian / Ubuntu / CentOS / RHEL / Fedora Linux or UNIX-like operating systems? Can you tell me the command to start or stop Apache 2 web server running on Linux?

Also read: How to Restore the Mysql databases from FRM and IBD files

Apache is primarily used to serve both static content and dynamic Web pages on the World Wide Web. Many web applications are designed expecting the environment and features that Apache provides. Apache can be started or restarted using any one of the following methods on Linux or Unix-like systems.

Ubuntu 18.04, 16.04, and Debian 9.x Commands

Start Apache Web Server

For Ubuntu users with versions 16.04 and 18.04 and Debian 9.x users, use the following commands in the terminal window to start Apache:

sudo systemctl start apache2

Check status to see whether Apache is enabled with the command:

sudo systemctl status apache2

If it is running, it should display the message active (running) as in the image above.

Stop Apache Web Server

Use the following commands in the terminal window to stop Apache:

sudo systemctl stop apache2

Check status to see whether Apache is disabled with the command:

sudo systemctl status apache2

If it has stopped running, it should display the message inactive (dead) as in the image below.

Restart Apache Web Server

To restart Apache use the command:

sudo systemctl restart apache2

Ubuntu 14.10 or older Debian

Debian Linux version 7.x or Ubuntu Linux version Ubuntu 14.10 or older:

Start Apache

For Ubuntu and Debian users with an older version, use the following commands in the terminal window to start Apache:

sudo service apache2 start

or

sudo /etc/init.d/apache2 start

Check status to see whether Apache is enabled with the command:

sudo service apache2 status

or

sudo /etc/init.d/apache2 status

It should display the message active (running).

Stop Apache

To stop Apache use the following command:

sudo service apache2 stop

or

sudo /etc/init.d/apache2 stop

Check status to see whether Apache is disabled with the command:

sudo /etc/init.d/apache2 status

It should display the message inactive (dead) as in the image below.

Restart Apache

To restart Apache use the command:

sudo service apache2 restart

or

sudo /etc/init.d/apache2 restart

Debian/Ubuntu Linux Specific Commands to Start/Stop/Restart Apache

CentOS/RHEL (Red Hat) Linux version 4.x/5.x/6.x or older specific commands

## Start ##
service httpd start
## Stop ##
service httpd stop
## Restart ##
service httpd restart

CentOS/RHEL (Red Hat) Linux version 7.x or newer specific commands

Most modern distro now using systemd, so you need to use the following systemctl command:
## Start command ##
systemctl start httpd.service
## Stop command ##
systemctl stop httpd.service
## Restart command ##
systemctl restart httpd.service

Follow TechBiriyani on FacebookTwitter to get all the latest updates.

Leave a Reply

Your email address will not be published. Required fields are marked *