Start / Stop and Restart Apache 2 Web Server Command

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 command to start or stop Apache 2 web server running on Linux?

Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements Apache 2 on Linux / Unix
Est. reading time 3 mintues
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.
How to start/stop/restart Apache 2 server on Linux/Unix?
First, login to your web-server using ssh client, if server is not in your local data center:
Once logged in type the following commands as per your Linux or Unix variant.

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

You can either use service or /etc/init.d/ command as follows on Debian Linux version 7.x or Ubuntu Linux version Ubuntu 14.10 or older:

Restart Apache 2 web server, enter:

# /etc/init.d/apache2 restart
$ sudo /etc/init.d/apache2 restart
$ sudo service apache2 restart

To stop Apache 2 web server, enter:

# /etc/init.d/apache2 stop
$ sudo /etc/init.d/apache2 stop
$ sudo service apache2 stop

To start Apache 2 web server, enter:

# /etc/init.d/apache2 start
$ sudo /etc/init.d/apache2 start
$ sudo service apache2 start

A note about Debian/Ubuntu Linux systemd users

Use the following systemctl command on Debian Linux version 8.x+ or Ubuntu Linux version Ubuntu 15.04+ or above:
## Start command ##
systemctl start apache2.service
## Stop command ##
systemctl stop apache2.service
## Restart command ##
systemctl restart apache2.service

We can view status using the following command:
$ sudo systemctl status apache2.service

 apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2021-02-24 20:39:39 UTC; 5 days ago
    Process: 115 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
    Process: 15247 ExecReload=/usr/sbin/apachectl graceful (code=exited, status=0/SUCCESS)
   Main PID: 128 (apache2)
      Tasks: 6 (limit: 4672)
     Memory: 16.4M
     CGroup: /system.slice/apache2.service
             ├─  128 /usr/sbin/apache2 -k start
             ├─15254 /usr/sbin/apache2 -k start
             ├─15255 /usr/sbin/apache2 -k start
             ├─15256 /usr/sbin/apache2 -k start
             ├─15257 /usr/sbin/apache2 -k start
             └─15258 /usr/sbin/apache2 -k start

Feb 27 00:00:23 ubuntu-db-mgmnt systemd[1]: Reloaded The Apache HTTP Server.
Feb 28 00:00:23 ubuntu-db-mgmnt systemd[1]: Reloading The Apache HTTP Server.

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

Alpine Linux start / stop / restart Apache 2 using openrc

We need to use the service command as root user:
# service apache2 start
# service apache2 stop
# service apache2 status
# service apache2 restart


 * Stopping apache2 ...
 * Starting apache2

FreeBSD Unix users

FreeBSD user can restart Apache as follows:
# /usr/local/etc/rc.d/apache22 restart
# service restart apache22
# service stop apache22
# service start apache22

Generic method to start/stop/restart Apache on a Linux/Unix

The syntax is as follows (must be run as root user):
## stop it ##
apachectl -k stop
## restart it ##
apachectl -k restart
## graceful restart it ##
apachectl -k graceful
## Start it ##
apachectl -f /path/to/your/httpd.conf
apachectl -f /usr/local/apache2/conf/httpd.conf

/usr/local/etc/rc.d/apache22 restart

Summing up

You learned how to start, stop or restart the Apache 2 web server using command-line over ssh-based session.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 26 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
26 comments… add one
  • test Nov 5, 2009 @ 19:45

    or try this: invoke-rc.d apache2 restart

  • sudhakara.alva Jan 1, 2010 @ 6:11

    reset apache.404 not found

  • Anonymous Jun 17, 2010 @ 21:39

    Sorry, this doesn’t work on Red Hat:
    /etc/init.d/apache2: command not found

    • 🐧 nixCraft Jun 17, 2010 @ 22:08

      For Redhat use:

      /etc/init.d/httpd restart
  • tipster Feb 9, 2011 @ 1:50

    If you want to stop,start, restart apache2 in Debian give this a try after su’ing

    /etc/init.d/apache2ctl stop
    or start restart what ever

  • Hasnat Apr 11, 2011 @ 9:09

    Sorry, this doesn’t work on Debian:
    /etc/init.d/apache2: command not found

    • alex Sep 28, 2011 @ 16:54

      remove the leading $ sign

  • ob1 May 8, 2011 @ 13:27

    service httpd start|stop|restart|status

  • pc-moon Aug 1, 2011 @ 23:38

    okey what is mean when this message coming to u : No apache MPM package installed

  • Hemant Thorat Jan 3, 2012 @ 6:04

    sudo service apache2 restart

  • emmanuel Mar 22, 2012 @ 3:45

    hello there,

    can someone help me out with how i can stop my apache from running.?

    • ivan Mar 25, 2012 @ 11:52


      /etc/init.d/apache2 stop
  • Fabio Tropia Feb 4, 2013 @ 10:10

    # service httpd restart
    …is better!

  • Aziz Aug 19, 2013 @ 6:31

    Can some one help me..
    When apache server restart then apache service will not working it shows…

    Not Found
    The requested URL / was not found on this server.
    Apache/2.2.22 (Debian) Server at Port 80

  • Miguel A. Acevedo Nov 15, 2013 @ 19:22

    Not Found
    The requested URL/ was not Found on
    this server cool

  • Jakub Sep 27, 2014 @ 15:52

    root@dermaproflin:/home/jakub# /etc/init.d/apache2 stop
    [….] Stopping web server: apache2apache2: Could not reliably determine the server’s fully qualified domain name, using for ServerName
    [ ok waiting .

  • fatma Oct 8, 2015 @ 4:57

    en utilisant la commande suivante :
    service httpd restart
    j’obtient le resultat suivant :
    Redirecting to /bin/systemctl start httpd.service
    Job for httpd.service failed. See “systemctl status httpd.service” and “journalctl -xe” for details.

    j’ai pas bien comprit ce resultat
    Pouvez vous m’aider svp

  • Arun May 6, 2016 @ 20:00

    Hi All,

    I am running three sites under /var/www/html.

    i want to restart a single site

    can you advice

  • selvamani Oct 19, 2016 @ 5:17


  • xgqfrms Dec 8, 2016 @ 18:18

    ## Start / Stop and Restart Apache 2 Web Server Command

    # Start Apache 2 web server
    $ sudo /etc/init.d/apache2 start
    $ sudo service apache2 start
    # Restart Apache 2 web server
    $ sudo /etc/init.d/apache2 restart
    $ sudo service apache2 restart
    # Stop Apache 2 web server
    $ sudo /etc/init.d/apache2 stop  
    $ sudo service apache2 stop
  • BDWEBIT Mar 20, 2017 @ 22:52

    Any one can help me for solve this problem occurred on centos vps(cpanel):

    Stopping httpd: [FAILED]
    Starting httpd: AH00526: Syntax error on line 12 of /etc/apache2/conf.d/modsec2.conf:
    ModSecurity: Failed to open the audit log file: /etc/apache2/logs/modsec_audit.log

  • Abo Oct 21, 2020 @ 10:05

    Hi, everyone!
    I have a problem.
    When i run, sudo service apache2 restart
    Nothing was change in server. And i did not show a Errors…

  • Papu Feb 20, 2021 @ 19:24

    Estaba buscando reiniciar el servidor Apache2 y esta página fue útil.

  • Matt Kimek Mar 20, 2021 @ 12:34

    I have running apache2 -DFOREGROUND and I realise that this is setup from docker. To check that do in 1 terminal

    docker events

    and in second one

    sudo killall apache2

    If it’s a docker setup, you should see docker events logs.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum