I switched from SLES to Ubuntu and now I want to restart my local server. In SLES I used:

rcapache2 restart

but this seems not to work in Ubuntu.

How do I restart Apache?

  • Next to apache2 there is also service apache-sp restart
    – Avatar
    Dec 16, 2021 at 6:47

13 Answers 13


sudo service apache2 restart for the way that's borrowed from Red Hat.

  • 1
    I think service is the LSB way, and should work in most distributions, now that Debian and Ubuntu finally got it. Oct 12, 2010 at 13:05
  • 11
    sudo restart apache2 is not working in Ubuntu 12.04. Not sure of other Ubuntu versions.
    – saji89
    Jan 29, 2013 at 7:42
  • 2
    @saji89 you need to do sudo service apache2 restart, then it will work.
    – Kevdog777
    Sep 18, 2014 at 13:09
  • 9
    sudo restart apache2 is not working in Ubuntu 14.04. sudo service apache2 restart is working tough.
    – toesslab
    Nov 22, 2014 at 12:54
  • sudo service apache2 reload works in some case Nov 15, 2022 at 6:19

Do you want to restart Apache, or do you want to gracefully reload its configuration?

Everyone was answering the first question; you can do the second with

sudo service apache2 reload

Gracefully reloading is a bit faster, and there's no downtime.

There's one caveat: if your apache config files contain an error (e.g. configures a log file in a directory that doesn't exist), the server may silently exit without printing any error messages to the console. Most other errors are caught by the apache2ctl configtest that service apache2 reload runs before doing the actual reload with apache2ctl graceful.

  • 1
    Yes! Use graceful is much better if you want to restart without kicking off your web site viewers!
    – tommed
    Oct 12, 2010 at 13:33
  • I find that it's an advantage of restart that if Apache isn't running then it will start. --> Will reload also start it? Jan 5, 2011 at 8:06
  • I don't think so -- even worse, reload will stop a running apache if you make a syntax error in the config file. Jan 6, 2011 at 20:19
  • 3
    Always run sudo apache2ctl configtest before doing graceful restart. Graceful restart will fail and apache will be stopped if config has a syntax error. Jun 2, 2016 at 9:17
  • @MikkoRantalainen: thanks, I've edited the answer to drop the raw apache2ctl graceful and instead recommend just service apache2 reload, which runs the configtest before graceful. Jun 2, 2016 at 18:41

The recommended way under Ubuntu to start/stop services (not just Apache) is to use the start/stop/reload commands (which really are symbolic links to the initctl program, part of upstart).

For services that use the legacy /etc/init.d scripts, the corresponding script will be called with the correct parameters; for services that use the upstart infrastructure, the appropriate event transition will be signaled to the upstart daemon via initctl.

So, to start/stop/reload/restart apache on Ubuntu, you can use:

sudo start apache2
sudo stop apache2
sudo reload apache2
sudo restart apache2
sudo /etc/init.d/apache2 restart

Of course you can swap out restart for stop, start and (I think) reload

  • 2
    When doing this under recent Ubuntu, you get a message about doing it the new way, although it will still carry out your the desired command.
    – jfmessier
    Oct 12, 2010 at 11:34
  • I didn't realised Apache had moved to Upstart yet.
    – Oli
    Oct 12, 2010 at 11:48
  • 1
    I don't see that message anymore.
    – Tim
    Jun 9, 2016 at 17:15

Ubuntu way:

  1. To restart:
    sudo service apache2 restart|stop|start 
  2. To stop:
    sudo service apache2 stop 
  3. To start:
    sudo service apache2 start 

As Marius said graceful should be used either to restart:

sudo apache2ctl graceful


sudo apache2ctl graceful-stop

to stop Apache gracefully.

These commands wait until all requests for web pages have been served before restarting/stopping the web server so that your user's don't get half a web page.


First you check your status using this command

sudo service apache2 status

then stop the running service

sudo service apache2 stop

then use this command:

sudo /opt/lampp/lampp start

this solution has worked for me.


You can use the systemctl command for apache service restarting; this controls the systemd system and service manager.

For Restarting Apache With systemctl Command:

sudo systemctl restart apache2.service

In case of being hung up or getting no response on restarting you can use the systemctl stop command to stop the service then start with the systemctl start command. Commands are as follows -

For Stopping Apache With systemctl Command:

sudo systemctl stop apache2.service

For Starting Apache With systemctl Command:

sudo systemctl start apache2.service

You can also use the reload command for only reloading the apache service.

For Reloading Apache With systemctl Command:

sudo systemctl reload apache2.service

you can use services for restarting Apache

service apache2 restart

and you can use all functionality for it (Stop - Start - Reload)


if you are install Apache 2.4 version in your system, to start restart or stop your Apache server on your local system,then you should run following command

./apachectl start

or you can use restart, stop also as per your requirement. this is tested code


The best way to restart your Apache server is by using the following command:

$ sudo service apache2 restart

Alter You can use the below command:

$ sudo /etc/init.d/apache2 restart
sudo systemctl restart apache2

systemctl - Control the systemd system and service manager.

systemctl may be used to introspect and control the state of the "systemd" system and service manager.


if you are root: (In Ubuntu root is disabled, I think, than use 'sudo' command!)

$ /etc/init.d/apache stop
$ /etc/init.d/apache start
$ /etc/init.d/apache restart
$ /etc/init.d/apache reload 

(If you used a2ensite or a2dissite, you have to reload your apache configuration)

  • root isn't disabled, it just doesn't have a password if you don't give it one yourself. Oct 12, 2010 at 11:05
  • 1
    is //stop apache supposed to be a comment? if so, standard shell notation would be #stop apache, // doesn't work in bash
    – Mikel
    Jan 24, 2011 at 8:05
  • @MikaelAuno root account is disabled if it doesn't have a password
    – T0xicCode
    Apr 16, 2012 at 0:25
  • 1
    @xav0989 That's quite the matter of definition. Sure you can't directly log in as root, or log in as root in any way that requires root's password for that matter, but there are other ways to become root. Try for example sudo -i followed by whoami and you'll see that you are indeed logged in as root. Also, if you do ps aux | grep root you'll see that you already have lots of processes on your system running as root. So, arguably, root is not disabled. Apr 19, 2012 at 16:33
  • @MikaelAuno or sudo -E -s. By disabled I'm assuming that what was meant is that you can't directly login as root, but you can still run processes as root.
    – T0xicCode
    Apr 19, 2012 at 20:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .