How to export environment variables to Apache httpd in RHEL
Issue
-
How can we export an environment variable to the
httpdservice 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/httpdand this works in RHEL6, but when wesystemctl start httpdin RHEL7, we get errors like this:systemd[1]: Ignoring invalid environment assignment 'export MY_CUSTOM_VARIABLE=prod.example.com': /etc/sysconfig/httpd -
In RHEL7, custom environment variables in
/etc/sysconfig/httpdare seen when usingapachectlbut aren't seen when starting apache withsystemctl start httpd. -
In RHEL7, custom environment variables in
/etc/sysconfig/httpdare seen when usingsystemctl start httpdbut not when usingapachectl.
Environment
- Red Hat Enterprise Linux
- Apache httpd
- Custom environment variables exported via
/etc/sysconfig/httpdor/etc/systemd/system/httpd*
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
