≡ Menu

Start / Stop and Restart Apache 2 Web Server Command

How do I restart an Apache 2 Web Server under a Debian / Ubuntu Linux or UNIX-like operating systems?

Tutorial details
DifficultyEasy (rss)
Root privilegesYes
RequirementsNone
Estimated completion time1m
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.

First, login to your web-server using ssh client, if server is not in your local data center:
ssh root@your.server.com
Once logged in type the following commands as per your Linux or Unix variant.

Debian/Ubuntu Linux Specific Commands

You can either use service or /etc/init.d/ command as follows

Restart Apache 2 web server, enter:

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

To stop Apache 2 web server, enter:

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

To start Apache 2 web server, enter:

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

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 command:
## Start command ##
systemctl start httpd.service
## Stop command ##
systemctl stop httpd.service
## Restart command ##
systemctl restart httpd.service

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

Tweet itFacebook itGoogle+ itPDF itFound an error/typo on this page?

{ 16 comments… add one }

  • test November 5, 2009, 7:45 pm

    or try this: invoke-rc.d apache2 restart

  • sudhakara.alva January 1, 2010, 6:11 am

    reset apache.404 not found

  • Anonymous June 17, 2010, 9:39 pm

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

  • tipster February 9, 2011, 1:50 am

    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 April 11, 2011, 9:09 am

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

    • alex September 28, 2011, 4:54 pm

      remove the leading $ sign

  • ob1 May 8, 2011, 1:27 pm

    service httpd start|stop|restart|status

  • pc-moon August 1, 2011, 11:38 pm

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

  • Hemant Thorat January 3, 2012, 6:04 am

    sudo service apache2 restart

  • emmanuel March 22, 2012, 3:45 am

    hello there,

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

    • ivan March 25, 2012, 11:52 am

      run

      /etc/init.d/apache2 stop
  • Fabio Tropia February 4, 2013, 10:10 am

    # service httpd restart
    …is better!

  • Aziz August 19, 2013, 6:31 am

    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 192.168.1.39 Port 80

  • Miguel A. Acevedo November 15, 2013, 7:22 pm

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

  • Jakub September 27, 2014, 3:52 pm

    Hi
    ?
    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 127.0.1.1 for ServerName
    [ ok waiting .

Leave a Comment