How to export environment variables to Apache httpd in RHEL
Issue
-
How can we export an environment variable to the
httpd
service and then use it in config files? Is this different between versions of httpd and versions of RHEL? -
We added environment variables to
/etc/sysconfig/httpd
and this works in RHEL6, but when wesystemctl start httpd
in RHEL7, we get errors like this:systemd[1]: Ignoring invalid environment assignment 'export MY_CUSTOM_VARIABLE=prod.example.com': /etc/sysconfig/httpd
-
In RHEL7 and RHEL8, custom environment variables in
/etc/sysconfig/httpd
are seen when usingapachectl
but aren't seen when starting apache withsystemctl start httpd
. -
In RHEL7 and RHEL8, custom environment variables in
/etc/sysconfig/httpd
are seen when usingsystemctl start httpd
but not when usingapachectl
.
Environment
- Red Hat Enterprise Linux
- Apache httpd
- Custom environment variables exported via
/etc/sysconfig/httpd
or/etc/systemd/system/httpd*
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.