1

Please do ask if you need any more information. I'm just trying to work out what is going on. So I have a server with nginx as the front end, and then passing along to Apache (2.4.18). In my Apache config file for the domain I have:

<VirtualHost *:8181>

    CustomLog /home/steampunkcom/web/uk.site.com/logs/uk.site.com.apache.log combined
    ErrorLog /home/steampunkcom/web/uk.site.com/logs/uk.site.com.apache.error.log

    LogLevel error

    RemoteIPHeader X-Forwarded-For

    # MOD_PERL
    LoadModule perl_module /usr/lib/apache2/modules/mod_perl.so

    ServerName uk.site.com
    ServerAlias www.uk.site.com
    ServerAdmin info@uk.site.com
    DocumentRoot /home/steampunkcom/web/uk.site.com/public_html

    # MOD_PERL
    PerlRequire  /home/steampunkcom/web/uk.site.com/startup.pl

    ScriptAlias /cgi-bin/ /home/steampunkcom/web/uk.site.com/public_html/cgi-bin/

    Alias /vstats/ /home/steampunkcom/web/uk.site.com/stats/
    Alias /error/ /home/steampunkcom/web/uk.site.com/document_errors/


    # Uncomment this part to make run as mod_perl - comment out above as well!
    <Directory "/home/steampunkcom/web/uk.site.com/*">

        Options +ExecCGI +FollowSymLinks +MultiViews
        AllowOverride AuthConfig

        PerlResponseHandler ModPerl::Registry
        AddHandler perl-script .cgi .pl
        Options +ExecCGI
        PerlOptions +ParseHeaders
        AllowOverride All
        Require all granted

    </Directory>

    <Directory /home/steampunkcom/web/uk.site.com/stats>
       AllowOverride All
       Require all granted
    </Directory>


    <IfModule mod_ruid2.c>
        RMode config
        RUidGid steampunkcom steampunkcom
        RGroups www-data
    </IfModule>
    <IfModule itk.c>
        AssignUserID steampunkcom steampunkcom
    </IfModule>

    IncludeOptional /home/steampunkcom/conf/web/apache2.uk.site.com.conf*

</VirtualHost>

This works fine. It runs under mod_perl well. The issue arises when I try and enable mod_perl on another user account:

<VirtualHost *:8181>

    CustomLog /home/willr/web/anothersite.co.uk/logs/anothersite.co.uk.apache.log combined
    ErrorLog /home/willr/web/anothersite.co.uk/logs/anothersite.co.uk.apache.error.log

    LogLevel error

    RemoteIPHeader X-Forwarded-For

    LoadModule perl_module /usr/lib/apache2/modules/mod_perl.so

    PerlRequire  /home/willr/web/anothersite.co.uk/startup.pl

    ServerName anothersite.co.uk
    ServerAlias www.anothersite.co.uk
    ServerAdmin info@anothersite.co.uk
    DocumentRoot /home/willr/web/anothersite.co.uk/public_html


    #####
    ScriptAlias /cgi-bin/ /home/willr/web/anothersite.co.uk/public_html/cgi-bin/
    #####

    Alias /vstats/ /home/willr/web/anothersite.co.uk/stats/
    Alias /error/ /home/willr/web/anothersite.co.uk/document_errors/

    <Directory "/home/willr/web/anothersite.co.uk/*">
        Options +ExecCGI +FollowSymLinks +MultiViews
        AllowOverride AuthConfig

        PerlResponseHandler ModPerl::Registry
        AddHandler perl-script .cgi .pl
        Options +ExecCGI
        PerlOptions +ParseHeaders
        AllowOverride All
        Require all granted

    </Directory>


    <IfModule mod_ruid2.c>
        RMode config
        RUidGid willr willr
        RGroups www-data
    </IfModule>
    <IfModule itk.c>
        AssignUserID willr willr
    </IfModule>

</VirtualHost>

At first I thought it was all working fine, but then I started getting emails from people telling me they couldn't log into the site. Upon looking into it, I found that it was sharing a module across the user accounts. I'm trying to figure out why, and what I can do about it. I know for a fact mod_perl can run across multiple user accounts without sharing the modules (as I've done it on other servers that were managed for me), but I'm not sure how/ why its doing it here.

Any ideas are much appreciated! In the meantime I've had to disable mod_perl for one of the sites, as it was causing too many issues for the other site :(

I just found something about using the +Parent and PerlSwitches config:

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

https://perl.apache.org/docs/2.0/user/config/config.html#C_Parent_

The problem though is that it still seems to cause the modules to get "shared" across other user accounts. So I have:

PerlOptions +ParseHeaders +Parent
PerlSwitches -Mlib=/home/steampunkcom/web/foo.co.uk/lib

When I look at the contents of @INC, I can see:

@INC = 
    /home/steampunkcom/web/foo.com/public_html/cgi-bin/admin
    /home/steampunkcom/web/foo.com/lib
    /etc/perl
    /usr/local/lib/x86_64-linux-gnu/perl/5.22.1
    /usr/local/share/perl/5.22.1
    /usr/lib/x86_64-linux-gnu/perl5/5.22
    /usr/share/perl5
    /usr/lib/x86_64-linux-gnu/perl/5.22
    /usr/share/perl/5.22
    /usr/local/lib/site_perl
    .
    /etc/apache2

I really thought I had a solution there, but maybe not :(

  • 1
    See my answer on PerlMonks :) – wazoox Mar 19 at 17:33
  • @wazoox thanks - I've replied there (not sure if you get notified, as I don't get emails when someone replies to me on PM) – Andrew Newby Mar 20 at 7:12
  • @wazoox hmmm yeah doesn't seem to work. Here are what I have (trimmed for sensative info) pastebin.com/1R2xeaxh , pastebin.com/LxXcsyxp – Andrew Newby Mar 20 at 7:18
  • you're not showing the other vhost. I'm pretty sure you must set the perl options for all the vhosts (because the default is "always share"). – wazoox Mar 20 at 15:23
  • @wazoox not sure what you mean? Those 2 pastebins are the different sites - unless you mean something else? There is only 2 sites that have mod_perl enabled (was one before, and now I'm trying to add a 2nd one, which is where the problem is coming from)( – Andrew Newby Mar 20 at 15:30
1

OK so this seems to work.

PerlOptions +Parent
PerlInterpStart 2
PerlInterpMax 2
PerlSwitches -Mlib=/home/steampunkcom/web/uk.domain.com/lib
PerlRequire  /home/steampunkcom/web/uk.domain.com/startup.pl # my script to auto load modules

It seems the order is important as well. I'm not sure if this was part of the solution as well, but I gave the server a reboot. I'm wondering if maybe something got "stuck" when I was playing with the settings, and no matter how many time I restarted Apache it wouldn't fix the issue.

Anyway - I think this has sorted it! At least I'm not seeming to get clashing modules any more.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.