【问题标题】:Phalcon controller not working using nginx on MAMPPhalcon 控制器无法在 MAMP 上使用 nginx
【发布时间】:2015-09-04 02:13:19
【问题描述】:

我正在使用 MAMP + nginx + phalcon 构建网站。我已经设置好所有东西并且 phalcon 正在工作,但它只看到 IndexController 和 indexAction。如果我添加更多控制器并尝试导航到它们,我会收到 404 错误。此外,如果我向 IndexController 添加另一个操作,我将无法访问它,并且再次收到 404 错误。这是我的 nginx 配置文件:

    server {
    listen               7888 default_server;

    root                 "/dev/testing/public";

    location / {
        index            index.html index.php;
    }

    location ~ \.php$ {
        try_files        $uri =404;
        fastcgi_pass     unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI.sock;
        fastcgi_param    SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include          fastcgi_params;
    }
}

我的 index.php 与 phalcon 文档中的给定索引相同。 任何建议/见解将不胜感激。

【问题讨论】:

    标签: php nginx mamp phalcon


    【解决方案1】:

    您的 nginx 配置文件应该将所有请求指向您的引导文件(通常是您的公共文件夹中的 index.php),并传递包含请求的原始路径的 _url 参数。

    这就是 Phalcon router 开箱即用的方式。

    正确的配置块可能会因项目的文件结构而异。因此,您需要阅读 Phalcon's Nginx Installation Notes 以了解您的特定情况需要哪些配置。

    【讨论】:

      【解决方案2】:

      尝试在这里查看 phalcon nginx 的文档https://docs.phalconphp.com/en/latest/reference/nginx.html,我能够使用这种配置,因为我们正在传递 _url 参数

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-11-29
        • 2021-10-19
        • 1970-01-01
        • 2021-12-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多