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.
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:
As Marius said graceful should be used either to restart:
sudo apache2ctl graceful
or
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 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.
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
sudo service apache2 restart
for the way that's borrowed from Red Hat.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
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
thatservice apache2 reload
runs before doing the actual reload withapache2ctl graceful
.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:
Of course you can swap out
restart
forstop
,start
and (I think)reload
Ubuntu way:
As Marius said graceful should be used either to restart:
or
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
then stop the running service
then use this command:
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: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 thesystemctl start
command. Commands are as follows -For Stopping Apache With
systemctl
Command:For Starting Apache With
systemctl
Command:You can also use the reload command for only reloading the apache service.
For Reloading Apache With
systemctl
Command:you can use services for restarting Apache
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
or you can use restart, stop also as per your requirement. this is tested code