Systemctl unit files

I can’t get Apache to start; systemctl error is:

/etc/systemd/system/httpd.service.d/override.conf:6: PIDFile= references a path below legacy directory /var/run/,…
httpd.service: Service has more than one ExecStart= setting, which is only allowed for Type=oneshot services. Refusing.

Neither of these statements is true; here is the override unit file:

Description=The Apache HTTP Server

ExecStart=/usr/sbin/httpd $OPTIONS -k start
ExecReload=/usr/sbin/httpd $OPTIONS -k graceful
ExecStop=/usr/sbin/httpd $OPTIONS -k stop





What is the best way to debug this and what is it likely seeing?

1 Like

Hate to reply to myself but the three lines with the large type are actually commented out in the unit file. Don’t know why the ## indicator doesn’t chow up.

try journal

Yur override file looks like a complete copy of the original unit file. This is completely wrong. override files are NOT meant to replace the original unit file, but instead are MERGED with the original.


If the original unit file has these lines:


and the override file has these lines:


Then the result used by systemd is:


And therfore, the error message is correct, as the result has 2 ExecStart lines.

Conclusion: Delete the override file:
sudo systemctl revert httpd.service

My guess is: The original reason for you to create the override is to fix this warning:
PIDFile= references a path below legacy directory

To do that, the override file should contain the ONLY the following 2 lines:


As a sidenote, the original does not use a pidfile, therefore this fix would not be required in the first place.
Perhaps, you better describe what you wanted to achieve by creating an override.

If you only want to add the dependency on php-fpm, then the override should contain (only) this:


And if you want to see the merged result of the original unit file and the overrride (sort of), then you can use:
sudo systemctl cat httpd.service
There is also:
sudo systemctl show httpd.service
but I find this rather coinfusing, because it shows everything (even defaults that are not explicitely set) and it does not show the config sections.

1 Like

Thanks for the explanation. I edited the file for two reasons; first to make httpd run in the background,and second to provide a shutdown process. I obviously thought that the override file would replace, not augment, the original. So I cribbed the unit file from the old server which shows httpd running as a background process with a fairly large number of children all with a command line of [path]httpd -k start. The paths on the old server are completely different from this new one. The change to the PIDfile was related to research I did on systemctl that suggested that this is a required line.
Thanks again everyone.

Sorry to bother you folks again but our apache server configuration requires mod_ssl to be loaded and that isn’t in the modules available in /usr/lib64/httpd/modules/ in the version of apache available from the Rocky repository. In the past this has always been a compile time choice when I pulled Apache from the web site. Do I have to do this now to obtain mod_ssl or am I missing something here?

mod_ssl is in it’s own package.
dnf install mod_ssl

The systemctl edit can do either of those, but the default is to augment.

man systemctl writes:

edit UNIT…
Edit a drop-in snippet or a whole replacement file if --full is specified, to extend or override the specified unit.

“dnf search” is good for finding missing features. A lot of large packages get broken up into sub-packages to reduce the disk footprint (and vulnerability) when a system doesn’t need all the bells and whistles.