Apache on Centos 7 - what is -DFOREGROUND ?


vpsBoard Premium Member
I yum'd httpd on a new Centos 7 box and when I did a ps (after systemctl start), I see

What is that?

If I change this in httpd.service:

#ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND
ExecStart=/usr/sbin/httpd $OPTIONS
...then it's just normal httpd.  But what is this -DFOREGROUND stuff?


To me running something in the foreground is a way to run a daemon without having it go in the background, so you can debug it, error messages print to the terminal, and you can kill it easily.  It would never be something that I'd choose as a default for a daemon...but I'm probably misunderstanding -DFOREGROUND.  Alas, Google did not help.


I would also like to take this opportunity to say how much systemd sucks.  Thank you.



New Member
Systemd is designed to run processes "in the foreground", that is, they don't have to specifically run themselves as daemons.  The processes don't exactly run in the foreground, they run under systemd and it captures their input and output, but from the process's perspective, it is the same as running in the foreground.  That is systemd's preferred method of operation, but it does have compatibility with traditional daemons.


vpsBoard Premium Member
That makes sense.  Well, in the sense that anything about systemd makes sense  :lol:


New Member
That foreground option is also used with docker. You always need a foreground process running in a docker instance. The normal apache way is to fork a background process and that causes docker to shutdown the instance. So you use either this -D FOREGROUND option or a separate program that manages daemons and keeps the container running.
Last edited by a moderator: