I know of three ways to restart Apache:

sudo /usr/sbin/apachectl restart

sudo /etc/init.d/apache2 restart

service apache2 restart

What does each way do underneath?

I have also tried using service apache2 stop on Ubuntu, but it doesn't stop the server for some reason: localhost still serves on my desktop.


service and/or init.d scripts are exactly the same thing as it runs same httpd script, that was meant mainly to stop and (re)start httpd service, while apachectl can do more (see output).


# apachectl 
Usage: /usr/sbin/httpd [-D name] [-d directory] [-f file]
                       [-C "directive"] [-c "directive"]
                       [-k start|restart|graceful|graceful-stop|stop]
                       [-v] [-V] [-h] [-l] [-L] [-t] [-S]
  -D name            : define a name for use in <IfDefine name> directives
  -d directory       : specify an alternate initial ServerRoot
  -f file            : specify an alternate ServerConfigFile
  -C "directive"     : process directive before reading config files
  -c "directive"     : process directive after reading config files
  -e level           : show startup errors of level (see LogLevel)
  -E file            : log startup errors to file
  -v                 : show version number
  -V                 : show compile settings
  -h                 : list available command line options (this page)
  -l                 : list compiled in modules
  -L                 : list available configuration directives
  -t -D DUMP_VHOSTS  : show parsed settings (currently only vhost settings)
  -S                 : a synonym for -t -D DUMP_VHOSTS
  -t -D DUMP_MODULES : show all loaded modules 
  -M                 : a synonym for -t -D DUMP_MODULES
  -t                 : run syntax check for config files
  • ok reason im asking s because i used sudo /usr/sbin/apachectl restart and all my django static files now give 404 errors, thought it had something to do with the method of server reboot – Dr Manhattan Nov 19 '14 at 16:36
  • @DrManhattan It's more likely that you had changed your configuration files (maybe with a rewrite). You did not notice it previously because the change did not take effect until you restarted the service. – kojow7 Sep 13 '18 at 21:41

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.