In Apache Core there is Define
, as per the documentation: link
Used to define variables
Define root_dir /var/www/meusite
<VirtualHost :80>
ServerName meusite.local
ServerAlias www.meusite.local
DocumentRoot ${root_dir}/public
ErrorLog ${root_dir}/__apache__.log
</VirtualHost>
On multiple hosts:
Define root_dir1 /var/www/meusite1
Define root_dir2 /var/www/meusite2
<VirtualHost meusite1.local:80>
ServerAlias www.meusite2.local
DocumentRoot ${root_dir1}/public
ErrorLog ${root_dir1}/__apache__.log
</VirtualHost>
<VirtualHost meusite2.local:80>
ServerAlias www.meusite2.local
DocumentRoot ${root_dir2}/public
ErrorLog ${root_dir2}/__apache__.log
</VirtualHost>
It's worth noting that if you use too many "includes" maybe one and a half may accidentally end up conflicting, and include something twice, in this case you can use <IfDefined>
to check if a file or if a variable has already been set
<IfDefine !FOO>
Include Foo.config
</IfDefine>
In this example, of course, there should be something like% w /
Define FOO valor
In addition to defining it is possible to remove a variable, like this:
<IfDefine FOO>
UnDefine FOO
</IfDefine>
It's good to point out this piece of documentation:
Virtual Host scope and pitfalls
While this directive is supported in virtual host context, the changes
it is visible to any later configuration directives, beyond any
enclosing virtual host.
Translating:
The scope of Virtual Host and its traps
Although this policy is supported in the context of Virtual Host, the changes made are visible to any later configuration policy, in addition to any other Virtual Host included.