2

We have this situation: - Apache running mod_perl - Multiple virtual hosts with own directories - Each virtual module has the same name for perl modules (development hosts, module differ a little bit, but have the same names) - Apache2::Reload for each virtual host to reload module on change

But apache throws 500 error on every 1/3 requests for the page reload and without specific error in the log, only warnings about "redefined functions".

Maybe there are some requirements to run the same module names but different paths and distinct them?

elgato
  • 321
  • 3
  • 13

2 Answers2

1

Here is how its done:

NameVirtualHost 192.168.0.140

<VirtualHost 192.168.0.140>
     PerlOptions +Parent
     PerlSwitches -Mlib=/path/to/application
     DocumentRoot /path/to/application
     ServerName name.domain.com
</VirtualHost>
user2218399
  • 94
  • 1
  • 4
  • This will not solve the namespace collision, and as I said in my answer, it is not possible to do so. The modules have to have different names or run in different Perl interpreters. – Dondi Michael Stroma Aug 22 '21 at 03:47
0

No, you cannot "run the same module name but with different paths". Perl just does not work that way. If you want to have multiple environments, keep them separate. You can run many Apache instances with different configurations (see the -f *configfilename* option) on various ports. Then in each vhost in the main server, reverse proxy to the back-end server on the corresponding port.

Dondi Michael Stroma
  • 4,668
  • 18
  • 21
  • "No, you cannot" - well, of course he can. That's what `-Mlib=~/lib` do. VirtualHosts can enable different lib paths for each one. – Francisco Zarabozo May 16 '21 at 20:24
  • @FranciscoZarabozo Wrong. Setting different library paths per virtual host does not allow you to load different modules with the same name. There is only one perl interpreter with one namespace. Loading a module named "A" and then loading a different module "A" from another library path will overwrite the previous one, that's why he is getting redefined warnings. – Dondi Michael Stroma Aug 22 '21 at 02:41
  • To be a bit clearer, you can load them, but the ensuing namespace collision will not give you a predictable or useful result. – Dondi Michael Stroma Aug 22 '21 at 03:00