andynewby

Member
Mar 14, 2014
5
0
1
cPanel Access Level
Website Owner
Hi all,

I've been going around in circles with this for a while now. I can't seem to find a definitive answer (bear in mind, I dabble with server stuff... but I'm far from a pro =))

I have 5 sites on my server. All of them ideally need to be under mod_perl. I've been told that they **shouldn't** share a mod_perl instance. Partly for security, but mainly due to the fact if you have Foo/Bar.pm in more than 1 site... it will ONLY load the instance from the first one - which is obliviously undesirable!). Previously, we only managed to get it on one site (the largest), due to the fact we added it into the pre_virtualhost_global.conf file (in the VirtualHost), and this meant that if we tried to use it on any others, it would have simply used the modules from the first site)

Could anyone shed some light on how I would enable it? This is a new server - so I can play around with it a bit (was hard to do on the old server, as its currently live... but this gives me a chance to play around, without affecting anything!)

TIA

Andy
 

andynewby

Member
Mar 14, 2014
5
0
1
cPanel Access Level
Website Owner
Hi,

Thanks for the reply. That looks similar to how we had it before, in the VirtualHost. i.e:

Code:
<VirtualHost 207.58.xx.xxx:80>
ServerName domain.org
ServerAlias www.domain.org
DocumentRoot /home/user/public_html
ServerAdmin username @domain.org
UseCanonicalName Off
CustomLog /usr/local/apache/domlogs/domain.org combined
CustomLog /usr/local/apache/domlogs/domain.org-bytes_log "%{%s}t %I .\n%{%s}t %O ."
ErrorLog /home/user/error_log

UserDir enabled user
<IfModule mod_suphp.c>
suPHP_UserGroup user user
</IfModule>
<IfModule !mod_disable_suexec.c>
<IfModule !mod_ruid2.c>
SuexecUserGroup user user
</IfModule>
</IfModule>
<IfModule mod_ruid2.c>
RUidGid user user
</IfModule>

PerlRequire /home/user/startup.pl
PerlModule Apache2::Reload
PerlInitHandler Apache2::Reload
PerlModule Apache2::RequestRec

ScriptAlias /cgi-bin/ /home/user/public_html/cgi-bin/

<Directory /home/user/public_html/cgi-bin>
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
PerlOptions +ParseHeaders
PerlOptions +SetupEnv
Options +ExecCGI
</Directory>

<Directory /home/user/public_html/cgi-bin/links/admin>
SetHandler cgi-script
</Directory>


# To customize this VirtualHost use an include file at the following location
# Include "/usr/local/apache/conf/userdata/std/2/user/domain.org/*.conf"

</VirtualHost>
This works with 1 site (if its the only one on the server using mod_perl). But as soon as you add it onto a 2nd domain, you find that the mod_perl instance "shares" the files from the first <VirtualHost> instance. For example, if we had 2 domains:

foobar.com
testing.com

Both had a structure of /cgi-bin/Foo/Bar.pm , which gets called in test.cgi.

If the first domain in the .conf file it comes across is foobar.com, then when test.cgi is called in EITHER of the domains - it would access Bar.pm from the foobar.cgi location (and totally ignore the testing.com version of it).

From my discussions on perlmonks, this is due to how apache/mod_perl work. If you don't have separate Apache instances per copy of mod_perl running, then you end up with cross caching. They're suggestion was to make the server run the domains totally separate from each other..i.e one copy of Apache for each of the domains we want to run mod_perl under (we don't care about those who don't usa mod_perl :))

Any ideas? I've been doing a lot of reading up, but I'm still no closer to finding a solution :(

TIA!

Andy
 

andynewby

Member
Mar 14, 2014
5
0
1
cPanel Access Level
Website Owner
Hi,

Thanks for the reply. So from what I understand, you're suggesting adding this into the <VirtualHost> for the given domains:

PerlOptions +Clone
PerlInterpStart 2
PerlInterpMax 2

...and this should run mod_perl seperate from the other domains?

I'll get a test install setup - and see how it goes :)

Thanks!

Andy
 

Shavaun

Well-Known Member
Aug 15, 2013
106
0
91
cPanel Access Level
Root Administrator
Check the Parent section too - this bit might be applicable:

Parent

Create a new parent Perl interpreter for the given VirtualHost and give it its own interpreter pool (implies the Clone option).

A common problem with mod_perl 1.0 was the shared namespace between all code within the process. Consider two developers using the same server and each wants to run a different version of a module with the same name. This example will create two parent Perl interpreters, one for each <VirtualHost>, each with its own namespace and pointing to a different paths in @INC:

META: is -Mlib portable? (problems with -Mlib on Darwin/5.6.0?)

<VirtualHost ...>
ServerName dev1
PerlOptions +Parent
PerlSwitches -Mlib=/home/dev1/lib/perl
</VirtualHost>

<VirtualHost ...>
ServerName dev2
PerlOptions +Parent
PerlSwitches -Mlib=/home/dev2/lib/perl
</VirtualHost>