3

After doing quite a lot of searching on google and here, I have not been able to find a solution to my problem.

I used this article to learn how to create variables inside my vhost. It requires mod_define to be installed.

I have a number of developers in my team who are working on the same project and all need to have the same settings applied to their vhosts. Modifying everyone's file is quite painful. So I have created a file called redirects.conf and included it into everyone's vhost. This file does not need to know about the DEV_DIR variable defined inside each vhost, so it works fine.

Example Developer vhost:

<VirtualHost devenv:80> Define DEV_DIR developer-name DocumentRoot /export/www/development/${DEV_DIR}/myproject/ ServerName pavan-myproject.dev.mydomain.co.nz Include /etc/httpd/conf/common/aliases.conf Include /etc/httpd/conf/common/rewrites.conf </VirtualHost> 

The aliases.conf file that I have included (or tried to) needs to be aware of and evaluate the value of the DEV_DIR variable.

Aliases file the gets included:

 Alias /secure/assests /export/www/development/${DEV_DIR}/myproject/assets/ Alias /secure/shareddata /export/script/data/shareddata 

After including this file, when I do a configtest, I get this error:

[error] mod_define: Variable 'DEV_DIR' not defined: file /etc/httpd/conf/common/aliases.conf, line 1

However, when I do not include that file and put the aliases straight into the vhost, it evaluates the DEV_DIR variable just fine (I have tried using both notations: ${DEV_DIR} as well as $DEV_DIR and both work). Doing this still requires changes to everyone's vhost. I would like to manage it using a single file.

I want to define variables with VirtualHost scope and have them available in the included files.

How do I get the aliases.conf or for that matter any other include file to evaluate the variables defined in the vhost that includes it?

What other solution can I use to implement such a functionality?

Can you please help me or link me to a solution if this question has been asked and answered elsewhere.

6
  • Could you try to define it outside of the VirtualHost? Just for the test. Commented Oct 15, 2014 at 2:07
  • I am using Apache/2.2.15 on Redhat Commented Oct 15, 2014 at 2:57
  • Thanx @Cheery, that still has the same effect. The variable does not get recognized. Commented Oct 15, 2014 at 3:00
  • I used this module in Apache under Windows and it was working without problem with included files. Commented Oct 15, 2014 at 3:06
  • Quick Google search suggests that there is a bunch of different mod_define implementations - try a few and see, perhaps one of them implements the functionality you need. Commented Oct 15, 2014 at 3:47

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.