nginx - php yaf配置问题

 虔州小小编_590 发布于 2022-11-14 04:11
#nginx.conf
        location /wx
        {
            root /wx/public/index.php;
            if (!-e $request_filename) {
              rewrite ^/wx/(.*)$ /wx/public/index.php?$1 last;
            }
        }
//public/index.php
bootstrap()->run();
#conf/application.ini
[product]
application.directory=APP_PATH "/application/" 
application.dispatcher.catchException = TRUE
application.dispatcher.throwException = TRUE
application.modules=index,admin
application.view.ext = 'php'

为什么这样配置,访问http://localhost/wx会提示

Page was not found
Failed opening controller script /home/wwwroot/default/wx/application/controllers/Wx.php: No such file or directory
#0 /home/wwwroot/default/wx/public/index.php(7): Yaf_Application->run()
#1 {main}

public/index.php打印$_REQUEST,是个空数组

目录结构:bootstrap.php在zapplication下,入口文件index.php在public下
补充一下,把域名绑定到/home/wwwroot/default/wx,用域名是可以访问的(rewrite规则要对应修改,不是上面那个),rewrite规则改成上面那个,再使用http://ip/wx访问(wx是yaf项目目录),就不行了。会把/wx/当成控制器

1 个回答
  • 终于有问Yaf的了,真开森,楼主上下您的结构吧,是Yaf 没找到你的引导。


    设定了adminindex 两模型,你将项目目录设定到../application/ 所以您的bootstarp,php也应该在这目录下,当bootstrap被调用的时刻, Yaf_Application就会默认的在APPLICATION_PATH下, 寻找Bootstrap.php, 而这个文件中, 必须定义一个Bootstrap类, 而这个类也必须继承自Yaf_Bootstrap_Abstract

    楼主不妨在控制器下建立wx.php尝试一下,结构有些乱哈

    2022-11-14 04:48 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有