14

The apache httpd server is seldom needed on one of our small servers, so it would be nice to start it via socket activation by systemd (and later stopped it when no traffic occurred for some time). Is this possible and if so, how?

1
  • Reworded the above, and the edit timed out at 5 minutes. The practical effects may not be useful. A client needs to connect with a 'startup' command before making normal requests. The client does not know ahead of time whether httpd is up, so the startup command needs to be sent before any normal requests. The delay will be high. In real life, the spiders and bots of the world may keep apache up perpetually. The question could be reworded to allow for answers like 'use a light weight http server like lighthttpd and leave it always-up'. – rleir May 21 '17 at 5:07
2

This is possible with Apache 2.5 with mod_systemd.

For older Apache releases, you may use systemd-socket-proxyd(8) but this will not automatically stop the Apache service after a timeout.

1
  • This is actually implemented in the server core, not in mod_systemd. (So building mod_systemd for Apache 2.4 won't get you socket activation.) – Julian Feb 17 '19 at 17:36
0

File:

httpd.socket

Content:

[Socket]
ListenStream=80
ListenStream=0.0.0.0:80
#BindIPv6Only=ipv6-only
After=network.target
Requires=network.target

[Install]
WantedBy=sockets.target

Make sure the apache service is also called httpd.

1
  • this does not works because the port is not forwarded to httpd.service from httpd.socket – Edward Torvalds Feb 14 '16 at 6:21

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.