I've just started using Debian 8 which has introduced systemd. I'm not interested in the politics around SysV vs systemd, but I am confused, especially around Apache (2.4).
There are now two ways to restart apache:
apache2ctl restart
orapache2ctl graceful
systemctl restart apache2
and it seemssystemctl restart apache2.service
does the same thing.
And they appear to do different things(!). I don't understand the difference.
I seem to need to do both to get a proper full restart working. e.g. after changing a config file for the php module it only noted the change after both.
Another time when apache2ctl configtest
was failing and the failure was reported in systemctl status apache2
I fixed the config so that the first of these commands was happy, restarted with apache2ctl restart
but the systemd status command still listed it as not running and with the old config problem.
I promise to spend ages reading about systemd (RTFM) in depth at some point, but meanwhile on a practical level relating to apache, I'd appreciate advice.
Best Answer
If you want consistency, always use
systemctl
forstop
,start
, andrestart
. That ends up using theapache2ctl
program - for now via the/etc/init.d/apache2
script but probably from a nativesystemd
unit file in the future.systemd
won't know when you've usedapache2ctl
directly, possibly resulting (as you've discovered) in a situation wheresystemd
thinksapache2
is still in a faulty state when it's actually running fine.For
configtest
andstatus
, useapache2ctl
. They just query apache without changing its state.