httpd conf environment variables - how do they work? (Centos 6)

httpd conf environment variables - how do they work? (Centos 6)

I have the following config included in my httpd.conf...

Include ${MODULE_DIR}/utilities/devconf/bo/vhost.conf

where ${MODULE_DIR} is an environment variable that I am setting in my httpd init script (/etc/init.d/httpd) like so:

MODULE_DIR=/export/home/modules

this line appears before the line that launches httpd.

Now when I attempt to start the Apache server using...

/etc/init.d/httpd start

I still get the following error:

[root@MyCentosVM ~]# /etc/init.d/httpd start
Starting httpd: httpd: Syntax error on line 1011 of /etc/httpd/conf/httpd.conf: Syntax error on line 1 of /etc/httpd/conf/devconf-vhosts.conf: Could not open configuration file /etc/httpd/${MODULE_DIR}/utilities/devconf/bo/vhost.conf: No such file or directory
                                                           [FAILED]
[root@MyCentosVM ~]#

... clearly the environment variable is not being substituted correctly. What do I do?

答案1

Try this instead:

export MODULE_DIR=/export/home/modules

相关内容