I have edited the variable AllowOverride for one of my websites in sites-enabled directory. How do I reload the new configuration without restarting apache? Is it possible?
-
8apache2 reload http://superuser.com/questions/192686/can-i-reload-apache2-configuration-file-without-issues – Christian Smorra Nov 25 '11 at 13:59
-
2Looks like all the answers are incorrect. – Tigran Dec 05 '18 at 07:41
-
1To clarify, the answers below are **valid at reloading** —although the commands for different distros differ (e.g. `apachectl` in CentOs or `apache2` in Ubuntu). But the concern is to do without restarting. All restart, but the graceful (`SIGUSR1`) solutions wait for no open connections to be broken. – Matteo Ferla Sep 28 '21 at 12:45
6 Answers
It should be possible using the command
sudo /etc/init.d/apache2 reload
-
19I am pretty sure this is not correct. Looking in the init.d-script of an Ubuntu server, reload refers to the graceful restart. This means that reload is in fact a restart, but gracefully. My opinion is that apache can't be reloaded without interrupting the service. – SteffenNielsen Mar 03 '17 at 12:54
-
8Aruman's answer is the correct one. Most Apache init scripts send SIGHUP which is equivalent to 'apachectl restart', which the OP specifically asked to avoid. Other Apache init scripts send SIGUSR1 which is equivalent to 'apachectl graceful', which is also a restart, but done more gracefully, and is what Aruman's answer provides. – Bryan Larsen May 04 '17 at 15:13
-
@SteffenNielsen I think you're right... Some will be fine with using a load balancer, disabling the one to be restarted, restarting, dealing with db versioning, then doing the same for the other apache server/container. K8s does away with some of these issues. – Ray Foss Jul 12 '18 at 15:45
-
I just tested this with a before/after `ps axf` comparison and it did do the restart (changed the CustomLog formatting) _without_ changing the PID. This was inside a docker container that was invoked with a custom entrypoint. Log format changed, didn't kill the container and same PID. – Elijah Lynn Mar 13 '19 at 00:38
-
1Okay, here is what happens, the main apache2 process doesn't change, but the children or workers (I don't know the right terminology) all restart, those PIDs do in fact change. – Elijah Lynn Mar 13 '19 at 00:43
-
1And I think graceful in this case just means that those children workers finish serving their requests before being killed and respawned. – Elijah Lynn Mar 13 '19 at 01:51
-
Do
apachectl -k graceful
Check this link for more information : http://www.electrictoolbox.com/article/apache/restart-apache/
-
24This will restart the Apache httpd daemon, which the question specifically asked to avoid. – cs01 Apr 20 '15 at 21:25
-
9@cs01 Where do you read that the httpd daemon will be restarted? Everything I read on the link provided in the answer says things like `apachectl graceful: Gracefully restarts the Apache daemon by sending it a SIGUSR1. If the daemon is not running, it is started. This differs from a normal restart in that currently open connections are not aborted.` – Tyler Collier Feb 18 '17 at 01:07
-
5The first sentence of the documentation you posted says just that, does it not? – cs01 Feb 18 '17 at 04:50
-
3@cs01 You need to understand why they are worried about a restart. That is not specified, but my guess is they don't want connections aborted, rather than a restart in itself. A graceful restart will do this fine in most cases. If there are long lived connections this maybe an issue though. You also need a good definition of restart as well, as all the graceful restart does is reinitialise the parent process ie the pid doesn't change, where as a normal restart tears down the whole process tree, and spawns a new one. Therefore Tyler Collier answer is perfectly legitimate. – krad Mar 01 '17 at 12:39
-
@cs01 This will not restart the server. See the [apache documentation](https://httpd.apache.org/docs/2.4/stopping.html#graceful), which states the command in this answer is how to perform a graceful restart. More detail in my newly added answer as well. – quickshiftin Feb 05 '21 at 18:05
-
1
-
1Besides this one was downvoted so many times, this is the best answer since the other two most upvoted answers suggests a thing that will do a non-graceful restart, which is even worse actually. Moreover, the service name can be some other than `apache2` (like `httpd` or `httpd2`) while the `apachectl` binary name will remain the same. – Ivan Shatsky Jun 22 '22 at 22:50
If you are using Ubuntu server, you can use systemctl
systemctl reload apache2

- 1,844
- 19
- 32
-
On ubuntu 18 (at least) this is an alias to `/usr/sbin/apachectl graceful` – Will S Feb 16 '21 at 11:37
Updated for Apache 2.4, for non-systemd (e.g., CentOS 6.x, Amazon Linux AMI) and for systemd (e.g., CentOS 7.x):
There are two ways of having the apache process reload the configuration, depending on what you want done with its current threads, either advise to exit when idle, or killing them directly.
Note that Apache recommends using apachectl -k
as the command, and for systemd, the command is replaced by httpd -k
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.

- 2,052
- 1
- 30
- 26
-
1apache 2.4.39 (win) does not support `httpd -k graceful` only `httpd -k restart`: `httpd /?` => `-k restart : tell running Apache to do a graceful restart` – Andreas Covidiot Apr 04 '19 at 09:36
Late answer here, but if you search /etc/init.d/apache2
for 'reload', you'll find something like this:
do_reload() {
if apache_conftest; then
if ! pidofproc -p $PIDFILE "$DAEMON" > /dev/null 2>&1 ; then
APACHE2_INIT_MESSAGE="Apache2 is not running"
return 2
fi
$APACHE2CTL graceful > /dev/null 2>&1
return $?
else
APACHE2_INIT_MESSAGE="The apache2$DIR_SUFFIX configtest failed. Not doing anything."
return 2
fi
}
Basically, what the answers that suggest using init.d, systemctl, etc are invoking is a thin wrapper that says:
- check the apache config
- if it's good, run
apachectl graceful
(swallowing the output, and forwarding the exit code)
This suggests that @Aruman's answer is also correct, provided you are confident there are no errors in your configuration or have already run apachctl configtest
manually.
The apache documentation also supplies the same command for a graceful restart (apachectl -k graceful
), and some more color on the behavior thereof.

- 66,362
- 10
- 68
- 89