我正在使用Mac Os High Sierra 10.13.06。我遵循了本指南https://discussions.apple.com/docs/DOC-12034,但是无法使我的perl脚本正常工作。浏览器只提供下载。我也尝试加载mod_cgi,但这没有帮助。
sudo apachectl -M
显示perl_module和cgi_module已加载。这是error_log文件:
[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'
这是我在/ 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脚本运行良好
如果您确实要使用mod_perl,并且模块已经加载,那么这对我有用。我将别名perl-bin用于mod_perl脚本。
`
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>
`
启用配置:`
a2enconf perl
`
文件/etc/apache2/startup.pl
1;
使用/ etc / lib / perl-bin中的脚本测试mod_perl]
打开网页并按F5几次,则计数应增加。...
`
#!/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"; }
`