Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

mod_perl, and weird caching

by ultranerds (Friar)
on Feb 04, 2014 at 15:27 UTC ( #1073419=perlquestion: print w/replies, xml ) Need Help??
ultranerds has asked for the wisdom of the Perl Monks concerning the following question:


Hopefully its ok to ask this question here, as I'm running out of ideas! First of all, I have 2 sites on my dedicated server - both I would like to run under mod_perl. The server is Apache2, is that helps.

Now - if I just have one site under mod_perl, all works fine. As soon as I add the 2nd one - I start seeing content from the other site "leaking" into the other site!

My configs are pretty much the same (just the path + userid + domain are changed):
<VirtualHost> ServerName ServerAlias DocumentRoot /home/fatpeter/public_html ServerAdmin UseCanonicalName Off CustomLog /usr/local/apache/domlogs/ combined CustomLog /usr/local/apache/domlogs/ "%{%s}t % +I .\n%{%s}t %O ." ErrorLog /home/fatpeter/error_log ## User fatpeter # Needed for Cpanel::ApacheConf UserDir enabled fatpeter <IfModule mod_suphp.c> suPHP_UserGroup fatpeter fatpeter </IfModule> <IfModule !mod_disable_suexec.c> <IfModule !mod_ruid2.c> SuexecUserGroup fatpeter fatpeter </IfModule> </IfModule> <IfModule mod_ruid2.c> RUidGid fatpeter fatpeter </IfModule> ScriptAlias /cgi-bin/ /home/fatpeter/public_html/cgi-bin/ PerlRequire /home/fatpeter/ PerlModule Apache2::Reload PerlInitHandler Apache2::Reload PerlModule Apache2::RequestRec <Directory /home/fatpeter/public_html/cgi-bin> SetHandler perl-script PerlResponseHandler ModPerl::Registry PerlOptions +ParseHeaders PerlOptions +SetupEnv Options +ExecCGI </Directory> <Directory /home/fatpeter/public_html/cgi-bin/links/admin> SetHandler cgi-script </Directory> # We dont wanna run this in mod_perl! <Files suggest.cgi> SetHandler cgi-script </Files> <Files community.cgi> SetHandler cgi-script </Files> <Files nph-build-custom.cgi> SetHandler cgi-script </Files> <Files admin.cgi> SetHandler cgi-script </Files> </VirtualHost>

Now, as I said - that works fine with just one domain. As soon as I add the 2nd one, I start to see variables being passed along wrong (incorrect image URLs, etc)

The only thing I can think of - is that we use the same module names... ie

Domain 1: /cgi-bin/foo/admin/lib/Plugins/ Domain 2: /cgi-bin/bar/admin/lib/Plugins/
Notice the folder names are different, but they would both translate as Plugins::Utils.

Now, the question is - how can I stop this "sharing" happening? The accounts are totally separate users, and shouldn't be sharing anything (if you try and change another accounts file, you get a permissions error.. which is totally how it should be)

Any suggestions? Its driving me up the wall only being able to run 1 site under mod_perl, without these undesired effects :/


Replies are listed 'Best First'.
Re: mod_perl, and weird caching
by MidLifeXis (Monsignor) on Feb 04, 2014 at 16:17 UTC

    The first vhost that loads a module wins. You have (at least) two approaches:

    • disambiguate by using different module names per vhost (ick)
    • use a single (common) module and configure the differences using a per-vhost configuration object.



      Thanks for the reply!

      I had a feeling you were gonna say that :/ For the different module names... that doesn't sound like fun! Would it work by for example, changing:

      domain 1: lib/Foo/
      domain 2: lib/Foo2/

      use a single (common) module and configure the differences using a per-vhost configuration object.
      Could you explain this a bit more?




        You would make your module generic, so that it works with all of your vhosts. You would then configure the code based on some vhost specific setting. So for example, if you have a vhost-specific configuration file indicating the graphics file names for specific UI components, you could configure that file name in a per-vhost PerlVar.

        In your code, you could access this per-vhost setting. You could then use that setting to identify the location of the configuration file for that vhost, read the configuration, and respond.

        Basically, a persistent environment like mod_perl assumes that you are not changing the foundation that you are building the application upon. In order for that to hold true, you need to isolate the moving parts into something that you pass through the building infrastructure.


      For anyone interested, we managed to get it going by adding into pre_virtualhost_global.conf, for each VirtualHost
      PerlOptions +Parent PerlSwitches -Mlib=/home/
      According to the Cpanel tech guys, this means that it will run a perl instance separately per domain (which is what we need)

      We've got it setup on 2 sites now, and as far as I can see its working a charm (no inter-sharing files at all - which is great!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1073419]
Approved by Corion
[talexb]: 2001 sounds about right .. got myself a separate box just to run Linux on. Seriously clueless.

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2018-07-17 17:56 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (374 votes). Check out past polls.