Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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>
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.
It is not a sound idea for Apache to have write access to scripts which it can run. So might be advisable to change the permissions back.
Quote:
Originally Posted by BluePukeko
RewriteMap hostname prg:/etc/apache2/hostname.sh
I'm not sure is an efficient way since the prg: method creates a bottleneck which pinches on each and every request to the server:
What you might do instead could be to use a separate, custom *.conf file, fetched via Include, which has contents which vary per server. There are several ways to do that.
From what I can deduce from further testing, the script is not being run.
My assumption has to be that permissions somewhere are preventing this from happening.
The script is located in /etc/apache2 directory:
drwxr-xr-x 116 root root 4.0K Apr 6 19:33 etc
drwxr-xr-x 11 www-data www-data 4.0K Apr 7 11:26 apache2
-rwxr-xr-x 1 www-data www-data 54 Apr 7 11:23 hostname.sh
the apache2 directory a mount point from the shared drive.
An obvious quick and dirty option to, at least temporarily, get around this would be to to have a hostname.conf file in the local file system that contains the required hostname
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.