Passing variables to httpd
I have installed RHEL 7.1 and Apache 2.4 on a server and I am able to serve up a web page. Now I am trying to configure Apache. From what I can see when I start apache using "systemctl start httpd.service" the script /usr/sbin/apachectl gets executed and sources in the contents from /etc/sysconfig/httpd.
I am not sure where RHEL's ownership ends and where Apache's ownership begins in this process. I have been told that the distro owns /etc/sysconfig/httpd and Apache owns /usr/sbin/apachectl but there does not appear to be any documentation on what is allowed in /etc/sysconfig/httpd.
What I want to do is pass variables to the httpd.conf file to drive some of the configuration and create more generic configuration files that can be shared between servers.
The following in supposed to be the correct syntax but that generates an error message.
export HTTPD_VAR1="devl"
Jun 10 06:24:56 server02 systemd[1]: Ignoring invalid environment 'export HTTPD_VAR1=devl': /etc/sysconfig/httpd
However if I split the line with the variable assignment first and the export second there is no error message and the variable is available in httpd.conf. Then I wanted to be a little more creative and assign a dynamic value to the variable with HTTPD_VAR2=hostname
and HTTPD_VAR3=$(hostname). This however did not work. What I got in the httpd.conf file was variables with values "hostname
" and "$(hostname)."
Looking on the web I found the following example to leads me to believe that what I want to do is something that is allowed.
export IPADDR_ETH0=$(ifconfig ens192 | grep inet | grep -v inet4 | awk '{print $2}' | sed -e s/addr://g)
So does anybody know what is allowed and what is not allowed in /etc/sysconfig/httpd? Any insight into this would be greatly appreciated.