如何为运行PSGI配置apache xampp窗口?

时间:2017-03-12 12:38:01

标签: perl

我在xampp windows中运行PSGI文件时遇到问题。

第一个我从CGI文件运行PSGI文件,然后工作,但是" $ request-> path_info"当我打印" $ request-> path_info"时,无法获取网址" / foo"和结果输出'' ?

"http://domain-exampe.org/foo" ---> output "$request->path_info" == ''.
"http://domain-exampe.org/" ---> output "$request->path_info" == ''.
"http://domain-exampe.org" ---> output "$request->path_info" == ''.

更新:添加更多信息(最初发布为问题的答案)

我创建名为" mypsgi.info"的本地域名,并在virtualhost apache中配置:

<VirtualHost 127.0.0.106>
    ServerName mypsgi.info
    DocumentRoot "D:/xampp/htdocs/psgi/test/"
    <Directory "D:/xampp/htdocs/psgi/test/">
        AllowOverride ALL
        Options Indexes FollowSymLinks Includes ExecCGI
        Require all granted
    </Directory>
</VirtualHost>

以及index.pl文件的内容:

#!"C:\Strawberry\perl\bin\perl" -w
use strict;
use warnings FATAL => 'all';

use Plack::Loader;
use Plack::Handler::CGI;
my $app = Plack::Util::load_psgi("app.psgi");
Plack::Loader->auto->run($app);

以及app.psgi文件的内容:

use strict;
use warnings FATAL => 'all';
use Plack::Request;
use Data::Dumper;

my $app = sub {

    my $req = Plack::Request->new(shift);
    my $path_info = $req->path_info;
    my $request_uri = $req->request_uri;
    my $_data = "
        <h3>Path Info : $path_info</h3>
        <h3>Request URI : $request_uri<h3>
    ";

    return [
        200,
        [ 'Content-type', 'text/html' ],
        [ $_data ],
    ];
};

如果我使用plackup app.psgi运行PSGI并在浏览器中访问localhost:5000/parent_path/child_path/输出:

Path Info : /parent_path/child_path/
Request URI : /parent_path/child_path/

如果我使用index.pl运行PSGI文件并访问我的域mypsgi.info/parent_path/child_path/,请在浏览器中输出:

Path Info :
Request URI : /parent_path/child_path/

为什么输出不同?

0 个答案:

没有答案