I have manually extracted and installed Apache server on my machine i.e. CentOs 7
Now I want to write a service script to start ,stop, etc Apache Server [ httpd ] for systemd.

How do I do that ?

What I have installed:

  1. apr-1.5.1.tar.gz
  2. apr-util-1.5.3.tar.gz
  3. pcre-8.35.tar
  4. openssl-1.0.2a.tar.gz
  5. httpd-2.4.9.tar.gz

Default httpd service Script is as :

.include /usr/lib/systemd/system/httpd.service

ExecStopPost=-/usr/bin/kdestroy -A
  • 2
    Please elaborate, what have you tried? Did you check the systemd man pages? They have quite a lot of information. You could also check the unit file that is shipped by CentOS with the default httpd package. Perhaps you could also explain why you can't or don't want to use the default packages as most of the packages you list appear to be available in the default repos.
    – Bram
    May 5, 2017 at 11:23

1 Answer 1


It's not clear what you are asking. Usually you just install from repositories and it is all created for you, but if you need to do all the work manually you should bear in mind that you probably want to use the command apachectl.

You should be able to achieve whatever it is you want to achieve just by reading the content of my /usr/lib/systemd/system/httpd.service file:

Description=Apache Web Server
After=network.target remote-fs.target nss-lookup.target

ExecStart=/usr/sbin/apachectl start
ExecStop=/usr/sbin/apachectl graceful-stop
ExecReload=/usr/sbin/apachectl graceful

  • thanks, I think this is default service I have to changed path to my apache installed directory,
    – shantaram
    May 6, 2017 at 5:18
  • 1
    Beware on Centos7 with Apache httpd 2.4 installed from the repos (yum, dnf), that apachectl no longer directly starts httpd, but instead is just a wrapper that makes systemctl calls. The httpd.service systemd unit file that gets installed by default with the RPM actually starts httpd directly. Under this configuration, if you wrote a unit file that called apachectl, it would simply loop. Ref lists.fedoraproject.org/pipermail/scm-commits/2012-January/… & pkgs.fedoraproject.org/cgit/rpms/httpd.git/commit/… Oct 19, 2017 at 15:34
  • If you look at the source of apachectl start it just runs systemctl start httpd.service. Isn't that infinite recursion?
    – Marc
    Nov 24, 2020 at 9:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .