1

I'm trying to get mod_perl working on Apache/2.4.18 (Ubuntu). Here is my main domain config file in Apache2:

<Virtualhost 0.0.0.0:8181>

    ServerName test
    DocumentRoot /srv/www/test.pro/www
    ErrorLog /srv/www/test.pro/logs/error.log

    <Directory "/srv/www/test.pro/www">
        Options MultiViews FollowSymLinks
        AllowOverride all
        Require all granted
    </Directory>

    ScriptAlias /cgi-bin /srv/www/test.pro/www/cgi-bin
    <Directory "/srv/www/test.pro/www/cgi-bin">
        AddHandler cgi-script .cgi
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Require all granted
        SetHandler cgi-script
     </Directory>

    <Location />
        LimitRequestBody 5242880
    </Location>
</VirtualHost>

This code does work...but, not with mod_perl. So, I'm doing the following to enable mod_perl:

<Virtualhost 0.0.0.0:8181>

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

    ServerName test
    DocumentRoot /srv/www/test.pro/www
    ErrorLog /srv/www/test.pro/logs/error.log

#######
# Added for the mod_perl - startup.pl runs fine when run in command line manually
# All the modules also exist
    PerlRequire  /srv/www/test.pro/startup.pl
    PerlModule Apache2::Reload
    PerlInitHandler Apache2::Reload
    PerlModule Apache2::RequestRec
#######

    <Directory "/srv/www/test.pro/www">
        Options MultiViews FollowSymLinks
        AllowOverride all
        Require all granted
    </Directory>

    ScriptAlias /cgi-bin /srv/www/test.pro/www/cgi-bin
    <Directory "/srv/www/test.pro/www/cgi-bin">
        AddHandler perl-script .cgi
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Require all granted
     </Directory>

    <Location />
        LimitRequestBody 5242880
    </Location>

</VirtualHost>

I then reboot Apache2, and try the site - and get an nginx error:

2017/03/28 12:40:51 [error] 22738#22738: *4 connect() failed (111: Connection refused) while connecting to upstream, client: 81.174.134.xx, server: test.pro, request: "GET /cgi-bin/trust/admin/admin.cgi HTTP/2.0", upstream: "http://127.0.0.1:8181/cgi-bin/trust/admin/admin.cgi", host: "test.pro"

I don't get what I'm doing wrong :/ Can anyone shed some light on what I'm missing? I've got it working fine on Apache/2.4.17 (Debian) on another server, so I can't figure out what I'm doing wrong here.

Thanks!

UPDATE: Mmm, so it seems to be startup my script that is causing the issue, but I'm not sure why. If I comment this line out, it all works:

PerlRequire  /srv/www/test.pro/startup.pl

I can't work out why though, as I get no errors (or even warnings!) when stopping/starting/restarting Apache :/

** UPDATE 2:**: I'm getting a little closer!

Can't load Perl file: /srv/www/test.pro/startup.pl for server test:0, exiting...

I double checked, and that is the correct path, and it runs fine when I run it with:

perl /srv/www/test.pro/startup.pl

...so I'm a bit baffled as to why its complaining!

Andrew Newby
  • 1,041
  • 1
  • 22
  • 48

1 Answers1

1

Eugh, well I'm not sure how helpful this is going to be to anyone who comes across it in the future, but I'll post it anyway - just in case it helps someone!

The problem was that I was missing literally 1 module: Apache::DBI, which was loaded by one of the mod_perl loader scripts called inside startup.pl.

Why oh why it couldn't have actually given me an error (or something in STDERR) that was a bit more helpful, I'll never know.

Anyway, the moral of the story is to check that ALL the modules you are trying to call, are actually installed :)

Andrew Newby
  • 1,041
  • 1
  • 22
  • 48