Skip to content

Instantly share code, notes, and snippets.

@blacksaildivision
Created November 12, 2016 14:39
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save blacksaildivision/199f9806dc68b2e7cf78713ae4631dfe to your computer and use it in GitHub Desktop.
Save blacksaildivision/199f9806dc68b2e7cf78713ae4631dfe to your computer and use it in GitHub Desktop.
SystemD (systemctl) script for managing Apache httpd compiled from source
[Unit]
Description=The Apache HTTP Server
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/apache2/bin/apachectl -k start
ExecReload=/usr/local/apache2/bin/apachectl -k graceful
ExecStop=/usr/local/apache2/bin/apachectl -k graceful-stop
PIDFile=/usr/local/apache2/logs/httpd.pid
PrivateTmp=true
[Install]
WantedBy=multi-user.target
@renatoanogueira
Copy link

Thank you Dude, it works here.

@tlsalex
Copy link

tlsalex commented Mar 24, 2020

thank you ,works well in my case

@cawoodm
Copy link

cawoodm commented Nov 24, 2020

If you look at the apachectl script it calls systemctl start httpd.service so you have infinite recursion here. Your service calls apachectl which starts the httpd service.

@blacksaildivision
Copy link
Author

If you look at the apachectl script it calls systemctl start httpd.service so you have infinite recursion here. Your service calls apachectl which starts the httpd service.

Thanks for the comment! This gist was made 4 years ago, it might have changed how apachectl works since then:) I just had a quick look onto the apachectl source code in the repo https://github.com/apache/httpd/blob/trunk/support/apachectl.in and it looks like that the script does not call systemctl directly but uses httpd binary instead. Didn't compile it though so the output might be different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment