配置的根目录是 public,为什么 resource_path()是 resources?

我想要的资源应该是public下。
但是

var_dump(resource_path());

返回

string(32) "/usr/local/var/www/tst/resources"

以下是nginx配置。

server {
    listen 80;
    server_name www.xxx.com;
    rewrite . /index.php;
    location / {
        index index.php index.html index.htm;
        autoindex on;
    }

    #proxy the php scripts to php-fpm
    location ~ \.php$ {
        root /usr/local/var/www/tst/public/;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /$document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
最佳答案

laravel里面resource_pathpublic_pathstorage_pathconfig_path的等访问路径的方法都是针对项目根目录而言的,与你网站配置在什么目录无关

5年前 评论
讨论数量: 11
leo

public_path()

5年前 评论

laravel里面resource_pathpublic_pathstorage_pathconfig_path的等访问路径的方法都是针对项目根目录而言的,与你网站配置在什么目录无关

5年前 评论

@leo 再请问下为什么login:10 GET http://www.tst.com/vendor/laravel-admin/Ad... 404 (Not Found);
直接URL输入这个也是找不到文件?

5年前 评论

@becage 因为vendor目录是不可公共访问的,建议通过bower安装到public目录下,只有public目录下的内容可以访问

5年前 评论

@FMW 我安装laravel-admin后,public目录下有这个vender,浏览器访问,http://www.tst.com/admin
http://www.tst.com/vendor/laravel-admin/Ad... 404 (Not Found);

file

5年前 评论

@becage 好吧,看错了,我还以为你这个vendorcomposervendor,你再仔细检查一下路径,看看路径是否有错

5年前 评论

@FMW 按理说public下的应该都能访问啊,直接url打开 public的/css/app.css,都是Sorry, the page you are looking for could not be found.

5年前 评论

@becage 你的nginx配置有问题,正确的伪静态规则是这样的

location / {
    try_files $uri $uri/ /index.php?$query_string;
}
5年前 评论

@FMW

server {
    listen 80;
    server_name www.latst.com;
    root /usr/local/var/www/tst/public/;
    rewrite . /index.php;
    location / {
        try_files $uri $uri/ /index.php?$query_string;
        index index.php index.html index.htm;
        autoindex on;
    }

    #proxy the php scripts to php-fpm
    location ~ \.php$ {
        include /usr/local/etc/nginx/fastcgi.conf;
        fastcgi_intercept_errors on;
        fastcgi_pass 127.0.0.1:9000;
    }
<link href="{{ asset('css/app.css') }}" rel="stylesheet">

file

5年前 评论

@becage 😓把你原来那些删了

rewrite . /index.php;

index index.php index.html index.htm;

autoindex on;

5年前 评论

@FMW 非常感谢!

rewrite . /index.php;

必须删掉

index index.php index.html index.htm;
        autoindex on;

不能删,不然报错forbidden。

5年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!