I switched from SLES to Ubuntu and now I want to restart my local server. In SLES I used:
but this seems not to work in Ubuntu.
How do I restart Apache?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
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
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
So, to start/stop/reload/restart apache on Ubuntu, you can use:
sudo start apache2 sudo stop apache2 sudo reload apache2 sudo restart apache2
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.
You can use the
systemctl command for apache service restarting; this controls the systemd system and service manager.
For Restarting Apache With
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
sudo systemctl stop apache2.service
For Starting Apache With
sudo systemctl start apache2.service
You can also use the reload command for only reloading the apache service.
For Reloading Apache With
sudo systemctl reload apache2.service