2

第一次发帖,好久没来了。

我在 plackup 中使用了一个小型 PSGI 应用程序,但我喜欢切换到 Apache2 的子域。我使用“ plackup /home/ath88/work/kolle/script/dir.psgi -port 80 ”运行应用程序。它可以完美地运行在 plackup 上。该应用程序非常简单,可以在https://github.com/ath88/Kolletilmelding/blob/master/script/dir.psgi找到

但是,出于显而易见的原因,我想运行 Apache2 而不是 plackup。为此,我想使用 Plack::Handler::Apache2。我的 VirtualHost 如下所示:

    <VirtualHost *:80>
      ServerName aths.dk
      ServerAdmin asbjoern@gmail.com
      <Location />
        SetHandler perl-script
        PerlResponseHandler Plack::Handler::Apache2
        PerlSetVar psgi_app /home/ath88/work/kolle/script/dir.psgi
      </Location>
    </VirtualHost>

Apache2 重新启动正常。但是当我尝试访问 aths.dk 时,我只是得到一个 404 未找到。应用程序的目录是正确的,因为它会导致 500 内部错误。查看 apache2/error.log 我得到这个:[无关,见编辑]

    [Wed Oct 05 21:32:16 2011] [notice] caught SIGTERM, shutting down
    [Wed Oct 05 21:32:17 2011] [notice] Apache/2.2.12 (Ubuntu) mod_perl/2.0.4 Perl/v5.10.0 configured -- resuming normal operations

每次我重新启动 Apache2 时都会发生这种情况。

我花了 4 个小时试图调试它。我完全难以置信。

编辑:原来 SIGTERM 是从停止 Apache2 重新启动。当我启动它时它不会发生。傻我。

4

1 回答 1

2

也许您的设置将受益于反向 HTTP 代理设置。

您可以手动启动您的 Plack 应用程序,并且可以将其绑定到127.0.0.1:9001而不是127.0.0.1:80,在这种情况下您需要一个特权用户(TCP 端口低于 1024 )。

然后一个应该工作的反向 HTTP 代理配置可能是这样的:

<VirtualHost *:80>
        ServerName aths.dk
        ServerAdmin asbjoern@gmail.com

        ErrorLog /var/log/apache2/aths.dk-error.log
        TransferLog /var/log/apache2/aths.dk.log
        DocumentRoot /var/www/aths.dk
        ProxyRequests Off

        <Proxy *>
                Order deny,allow
                Allow from all
        </Proxy>
        ProxyPass / http://127.0.0.1:9001/
        ProxyPassReverse / http://127.0.0.1:9001/
</VirtualHost>
于 2011-10-06T08:04:34.830 回答