简体   繁体   English

Apache2 mod_perl下的Catalyst应用程序不会呈现Mason模板

[英]Catalyst application under Apache2 mod_perl won't render Mason templates

my application root is /home/user/apps/learningcatalyst/CGAddressBook in that folder I have a /mason folder where mason components are stored my View is located in /lib/CGAddressBook/View where I have a few files called login_form and addressbook. 我的应用程序根目录是该文件夹中的/ home / user / apps / learningcatalyst / CGAddressBook,我有一个/ mason文件夹,其中存储了梅森组件。我的View位于/ lib / CGAddressBook / View中,我有一些名为login_form和地址簿的文件。

Couldn't render component "login_form" - error was "could not find component for initial path '/login_form' (component roots are: '/home/user/apps/learningcatalyst/CGAddressBook/lib/CGAddressBook/View') is the error I get when trying to reach the site through Apache. My apache conf file is 无法呈现组件“ login_form”-错误为“找不到初始路径'/ login_form'的组件(组件根目录为:'/ home / user / apps / learningcatalyst / CGAddressBook / lib / CGAddressBook / View')是错误我尝试通过Apache到达站点时得到了我的apache conf文件是

PerlSwitches -I/home/user/apps/learningcatalyst/CGAddressBook/lib
PerlModule CGAddressBook

<Location /user_catalyst/>
    SetHandler modperl
    PerlResponseHandler CGAddressBook
</Location>

DocumentRoot /home/user/apps/learningcatalyst/CGAddressBook/root
<Location /user_catalyst/static>
    SetHandler default-handler
</Location>

All folders are readable by user, its group, and other. 用户,其组及其他均可读取所有文件夹。 The mason folder, where Mason is set to write its cache, is set to read, write, and execute by user, group, and other. 梅森文件夹(已将梅森设置为写入其缓存)设置为按用户,组等进行读取,写入和执行。 Its owner is user. 它的所有者是用户。 I have restarted Apache to no avail, I have changed folder owners (and recursively) of both the /View and /mason. 我没有重新启动Apache,但已经更改了/ View和/ mason的文件夹所有者(并以递归方式)。

The application works just fine when running script/cgaddressbook_server.pl -r -p3001 and I go to my site on port 3001. 当运行script / cgaddressbook_server.pl -r -p3001时,该应用程序运行良好,并且我通过端口3001进入我的站点。

The path to comp_root is meant to be the path to your template "components". comp_root的路径是指模板“组件”的路径。 You appear to be pointing it at the same directory as the "View" package. 您似乎将其指向与“查看”包相同的目录。 You "might" actually have the components there but that is not really a good practice. 您实际上可能在那里拥有组件,但这并不是一个好习惯。

The default location without specifying this should be the "root/comps" folder ( or something like that ) in your Catalyst project structure. 未指定此默认位置的默认位置应该是Catalyst项目结构中的“ root / comps”文件夹(或类似的文件夹)。 One of my own samples is like this: 我自己的样本之一是这样的:

package SnakierTen::Web::View::HTML;
use Modern::Perl;
use Moose;
use MooseX::NonMoose;

extends 'Catalyst::View::Mason2';

around BUILDARGS => sub {
    my ( $orig, $class, $c, @args ) = @_;

    $class->config(

        comp_root => $c->path_to( 'root' ),
        data_dir  => $c->path_to( 'data' ),

        plugins => [
            'TidyObjectFiles',
            'HTMLFilters',
        ],
    );

    $class->$orig( $c, @args );

};

__PACKAGE__->meta->make_immutable;
no Moose;
1;

Aside from that, direct support of Mod Perl handlers is being deprecated in Catalyst core. 除此之外,在Catalyst核心中不建议使用Mod Perl处理程序的直接支持。

The favored method is to start the application under it's own PSGI compliant server and use a "front end" web server to "proxy" the requests to this application server. 首选的方法是在自己的PSGI兼容服务器下启动应用程序,并使用“前端” Web服务器将请求“代理”到该应用程序服务器。

Where you must run the application under a mod_perl environment, it is still recommended to run under a PSGI handler. 必须在mod_perl环境下运行应用程序的地方,仍然建议在PSGI处理程序下运行。 There are some notes here that are a part of the documentation yet to be built on this. 还有一些注意事项这里是文件尚未在此建造的一部分。 You can use the methods there to guide you in doing this. 您可以使用那里的方法来指导您执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM