+ -
当前位置:首页 → 问答吧 → nginx+php使用相对路径的问题求解

nginx+php使用相对路径的问题求解

时间:2009-05-25

来源:互联网

本帖最后由 joyanhui 于 2009-5-25 11:47 编辑

在nginx下的html目录 很正常[code]server {
listen 8080;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;

}
}[/code]上级目录为何只解析html不解析php?[code]
server {
        listen       8081;
        server_name  localhost;
        location / {
            root   ../htdocs;
            index  index.html index.htm;
        }
        error_page  404              /404.html;
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   ../htdocs;
        }
        location ~ \.php$ {
            root           ../htdocs;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi_params;
        }
}
[/code]

作者: joyanhui   发布时间: 2009-05-25

location ~ \.php$ {

            root           ../htdocs;#这里 为什么不能用相对路径?

            fastcgi_pass   127.0.0.1:9000;

            fastcgi_index  index.php;

            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

            include        fastcgi_params;

        }

作者: joyanhui   发布时间: 2009-05-25

你自己不是已经回答了吗
root           ../htdocs;#写法错误,本应该连HTML都解析不了的,具体原因,你可以自己分析NGINX代码,它是开源的。

作者: xieaotian   发布时间: 2009-05-26

相对目录 应该如何写?
我要是能分析ningx源码 就不会在这里问啦,晕菜了

作者: joyanhui   发布时间: 2009-05-27

我也测试过这个问题,没有成功,暂时得出的结论是不支持,继续关注

作者: peacock   发布时间: 2009-05-27