Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache 2 - reload config on Windows

I have a PHP script that modifies my httpd.conf file, so I need to automatically reload it in Apache.

On Linux, there is graceful restart, but on Windows (I use the restart command) it terminates all the current connections. Is there a command as graceful restart on Windows? Is there a workaround on this?

like image 314
Alin Florin Avatar asked Jun 26 '13 22:06

Alin Florin


2 Answers

Yes, you should use the -k switch.

   httpd.exe -k restart or apache.exe -k restart 

More info here has well. http://www.zrinity.com/developers/apache/usage.cfm

Edit:

It shouldn't that is the point of Graceful. Notice I used the -k. That is not the same as a normal restart. It let's the current sessions complete their task while the config is being reread, so that it will start taking new requests immediately.

From the documentation:

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. As each child dies off the parent replaces it with a child from the new generation of the configuration, which begins serving new requests immediately.

http://httpd.apache.org/docs/2.2/stopping.html#graceful

It's doing what you are asking for.

Edit 2:

Adding this link and gave both possible versions because some people think you there is only one specific way to do something instead of search themselves.

http://httpd.apache.org/docs/2.4/platform/windows.html#wincons

I think I'm just going to delete this answer because either people can't read or if it doesn't work for someone it gets a DV. There are different windows versions made by different developers. If it doesn't work look for the answer from them. Even Linux has different commands depending on the distro. geez

like image 169
Panama Jack Avatar answered Sep 20 '22 20:09

Panama Jack


In the newest Apache 2.4.20 VC10 the "httpd -k restart" command actually DOES do a graceful restart. It won't drop any connections, for example if somebody is downloading something from your server, it WILL NOT interrupt this process. One more proof is that "-k restart" will not reset your server statistics that mod_status provides, won't even alter the "Restart Time" value.

Although "httpd -k graceful" and "httpd -k graceful-stop" commands are available in Windows, but they will not work giving an error "couldn't make a socket".

like image 33
Ronaldo Avatar answered Sep 18 '22 20:09

Ronaldo