我试图让mod_perl在Apache / 2.4.18(Ubuntu)上工作 。 这是我在Apache2中的主要域configuration文件:
<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>
这段代码可以工作,但不是用mod_perl。 所以,我正在做以下启用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>
然后我重新启动Apache2,并尝试网站 – 并得到一个nginx错误:
2017/03/28 12:40:51 [error] 22738#22738:* 4连接()失败(111:连接被拒绝)连接上游时,客户端:81.174.134.xx,server:test.pro,request: “GET /cgi-bin/trust/admin/admin.cgi HTTP / 2.0”,上游:“ http://127.0.0.1:8181/cgi-bin/trust/admin/admin.cgi ”,主机:“testing。亲”
我不明白我做错了什么:/任何人都可以阐明我错过了什么? 我已经在另一台服务器上的Apache / 2.4.17(Debian)上正常工作,所以我无法弄清楚我在这里做错了什么。
谢谢!
更新:嗯,所以它似乎是启动我的脚本导致的问题,但我不知道为什么。 如果我评论这条线,这一切工作:
PerlRequire /srv/www/test.pro/startup.pl
我不知道为什么,因为当停止/启动/重新启动Apache时,我没有遇到任何错误(甚至是警告!):/
**更新2:**:我正在接近一点!
无法加载Perl文件:/srv/www/test.pro/startup.pl服务器testing:0,正在退出…
我加倍检查,这是正确的path,它运行正常,当我运行它:
perl /srv/www/test.pro/startup.pl
…所以我有点困惑,为什么它抱怨!
Eugh,以及我不确定将来遇到这种情况的人会有多大的帮助,但是我仍然会将其发布 – 以防万一!
问题是,我只是丢失了一个模块: Apache :: DBI ,它是由startup.pl中调用的一个mod_perl加载器脚本加载的。
为什么哦,为什么它实际上没有给我一个错误(或STDERR中的东西),这是多一点帮助,我永远不会知道。
无论如何,故事的寓意是检查你试图调用的所有模块,实际上是安装:)