Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between apache2 reload, restart, graceful?

Tags:

apache2

I am using apache2 for a project and I am wondering what is exactly the difference between these commands:

service apache2 restart service apache2 reload service apache2 graceful 
like image 719
VDarricau Avatar asked Jul 22 '15 15:07

VDarricau


People also ask

What does Apache graceful restart do?

Graceful Restart The USR1 or graceful signal causes the parent process to advise the children to exit after their current request (or to exit immediately if they're not serving anything). The parent re-reads its configuration files and re-opens its log files.

What is Apache reload?

restart : Stops and then starts the Apache service. reload : Gracefully restarts the Apache service. On reload, the main Apache process shuts down the child processes, loads the new configuration, and starts new child processes.

What is Apachectl restart?

apachectl restart: Restarts the Apache daemon by sending it a SIGHUP. If the daemon is not running, it is started. This command automatically checks the configuration files via configtest before initiating the restart to make sure Apache doesn't die. fullstatus: Displays a full status report from mod_status.


2 Answers

There main difference between the four different ways of stopping/restarting are what does the main process do about its threads, and about itself.

Note that Apache recommends using apachectl -k as the command, and for systemd, the command is replaced by httpd -k


apachectl -k stop or httpd -k stop

This tells the process to kill all of its threads and then exit


apachectl -k graceful or httpd -k graceful

Apache will advise its threads to exit when idle, and then apache reloads the configuration (it doesn't exit itself), this means statistics are not reset.


apachectl -k restart or httpd -k restart

This is similar to stop, in that the process kills off its threads, but then the process reloads the configuration file, rather than killing itself.


apachectl -k graceful-stop or httpd -k graceful-stop

This acts like -k graceful but instead of reloading the configuration, it will stop responding to new requests and only live as long as old threads are around. Combining this with a new instance of httpd can be very powerful in having concurrent apaches running while updating configuration files.


Source: https://httpd.apache.org/docs/2.4/stopping.html

Recommendation: Use -k graceful unless there is something wrong with the main process itself, in which case a combination of -k stop and -k start or -k graceful-stop and -k start are the options of choice.

like image 133
jeffmcneill Avatar answered Sep 18 '22 08:09

jeffmcneill


  1. Difference between “restart” and “reload”

    • Restart= stop + start
    • Reload = remain running + re-read configuration files.
  2. Normal restart and graceful restart, you can reference article:

    https://teckadmin.wordpress.com/2013/10/23/difference-between-graceful-restart-and-normal-restart/

like image 25
Phi Thien Than Avatar answered Sep 20 '22 08:09

Phi Thien Than