0

I'm using Mac Os High Sierra 10.13.06. I followed this guide https://discussions.apple.com/docs/DOC-12034, but couldn't make my perl script work. The browser just offers to download it. I also tried loading mod_cgi, but that didn't help.

sudo apachectl -M

shows that perl_module and cgi_module are loaded. Here is the error_log file:

[Tue Dec 10 11:02:01.586530 2019] [mpm_prefork:notice] [pid 77] AH00169: caught SIGTERM, shutting down
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using MacBook-Air-Nikita.local. Set the 'ServerName' directive globally to suppress this message
[Tue Dec 10 11:02:01.912225 2019] [mpm_prefork:notice] [pid 504] AH00163: Apache/2.4.33 (Unix) PHP/7.1.16 mod_perl/2.0.9 Perl/v5.18.2 configured -- resuming normal operations
[Tue Dec 10 11:02:01.912331 2019] [core:notice] [pid 504] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'

it is my config file in /etc/apache2/users

<Directory "/Users/nikitakirenkov/Sites/">
        AddLanguage en .en
        AddHandler perl-script .pl
        PerlHandler ModPerl::Registry
        Options Indexes MultiViews FollowSymLinks ExecCGI
        AllowOverride None
        Require host localhost
</Directory>

php scripts work well

1 Answers1

1

If you really want to use mod_perl, and the module is already loaded, then this works for me. I use alias perl-bin for mod_perl scripts.

  1. File /etc/apache2/conf-available

`

PerlModule ModPerl::Registry
PerlModule Apache::DBI;    
PerlModule Apache2::compat;

PerlPostConfigRequire /etc/apache2/startup.pl

ScriptAlias /perl-bin/ /usr/lib/perl-bin/
<Directory "/usr/lib/perl-bin">
       AllowOverride None
       Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
       SetHandler perl-script
       PerlResponseHandler ModPerl::Registry
       PerlOptions +ParseHeaders
       Require ip 127.0.0.1 192.168.0.0/16
</Directory>

`

Enable the config: `

a2enconf perl

`

  1. File /etc/apache2/startup.pl

    1;

  2. Test mod_perl with a script in /etc/lib/perl-bin

Open the webpage and press F5 several times then the count should increase....

`

#!/usr/bin/perl
use strict;
use vars qw($count);
use utf8;

my $mod_perl_in_use = $ENV{MOD_PERL_API_VERSION};

print "<h1>Count test </h1>";
print "<b>Mod_perl test script</b><br><br>\n";
$count++;
print "The following count will start at 1 and will increment by 1 on each refresh \n";
print "(If this was a non-mod_perl script, the counter would always be 1).<br>\n";
print "count = $count\n<br><br>";
print "pid = $$\n<br><br>";

if ($ENV{'MOD_PERL'}) {
    print "Mod_perl is installed on this server: $ENV{'MOD_PERL'}<br><br>\n";
} else {
    print "Mod_perl is not installed on this server<br><br>\n";
}

print "<b>Environment variables</b><br>\n";
foreach my $key (sort keys %ENV)
{
    print "\"$key\" = \"$ENV{$key}\"<BR>\n";
}

`

Dave Cross
  • 68,119
  • 3
  • 51
  • 97
Rob Lassche
  • 841
  • 10
  • 16