6

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:

  1. apache2ctl restart or apache2ctl graceful
  2. systemctl restart apache2 and it seems systemctl 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.

6

If you want consistency, always use systemctl for stop, start, and restart. That ends up using the apache2ctl program - for now via the /etc/init.d/apache2 script but probably from a native systemd unit file in the future.

systemd won't know when you've used apache2ctl directly, possibly resulting (as you've discovered) in a situation where systemd thinks apache2 is still in a faulty state when it's actually running fine.

For configtest and status, use apache2ctl. They just query apache without changing its state.

2
  • So systemctl status doesn't use apache2ctl? – artfulrobot Nov 4 '15 at 8:36
  • 3
    systemctl status apache2 tells you if the service is running. apache2ctl status gives you the output from mod_status if it is enabled and configured. – cas Nov 4 '15 at 9:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.