Article 6KWK8 Embedding script in apache2.conf

Embedding script in apache2.conf

by
BluePukeko
from LinuxQuestions.org on (#6KWK8)
I have an "interesting" problem, mostly caused by my curiosity, that I hope somebody can shine a light on for me.
I have a number of VM's running under ProxMox with one being a NFS server to share the majority of the disk space over all the VM's rather than guessing the amount of disk that each VM will require for data storage.
While I've only got two VM's running apache so far, I will probably have most of them doing so.
The set up so far has the two VM's sharing the /etc/apache directory and therefore sharing the apache.conf file.
Obviously each of the VM's will need to, at a minimum, access different website conf files, which is where my problem comes in.
I've written a small bash script that displays the hostname of the machine and using RewriteMap to capture the output of the script and store that in an environment variable which I then use to a) set the servername and b) include the required website conf files.

The script when ran outside of apache, as root, runs and displays the machine hostname. I changed the owner group to www-data:www-data and still no joy within Apache load or restart.
Script permissions are: xrwxr-xr- so should run happily when called from apache.

The coding within apache2.conf is:

RewriteEngine on
RewriteMap hostname prg:/etc/apache2/hostname.sh

# Use IfDefine to include configuration based on the value of HOSTNAME
<IfDefine HOSTNAME>
# Include configuration file based on hostname
IncludeOptional hosts-available/%{ENV:HOSTNAME}.conf
</IfDefine>

**** AND

<IfDefine HOSTNAME>
# Include virtual machine sites-enabled file(s) based on hostname
<If "%{ENV:HOSTNAME} == 'bpg169.HOST'">
# Directives specific to 120.138.17.169
IncludeOptional sites-enabled/bluehost/*.conf
IncludeOptional sites-enabled/bluepress/*.conf
IncludeOptional sites-enabled/bluewiki/*.conf
</If>
<ElseIf "%{ENV:HOSTNAME} == 'bpg-170-DATA'">
# Directives specific to 120.138.17.170
IncludeOptional sites-enabled/bluedata/*.conf
</ElseIf>
</IfDefine>



Appreciate help in spotting the problem
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments