duanbi8089 2019-08-05 13:59 采纳率: 100%
浏览 135

如何使用nginx别名为php-fpm设置正确的root?

I would like to change the html/php root for every user in a separate directory like:

abc12345 has its root-directory for html/php at: /home/abc12345/html/

This works already for non-php-files with following configuration:

     location ^~ /abc12345 {

            alias /home/abc12345/html;
            index index.php;

            location ~ \.php$ {
                    #include fastcgi_params;
                    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

                    fastcgi_param PATH_INFO $fastcgi_path_info;
                    fastcgi_intercept_errors on; 

                    fastcgi_param HTTPS on; 

                    fastcgi_split_path_info ^(.+?\.php)(/.*)$;

                    try_files $fastcgi_script_name =404;

                    set $path_info $fastcgi_path_info;
                    fastcgi_param PATH_INFO $path_info;

                    fastcgi_index index.php;
                    include fastcgi.conf;

                    fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
                    #try_files $uri =404;
            }


     }

As soon as I pass an php-file this does not work, cause the SCRIPT_FILENAME will try to search under /home/abc12345/html/abc12345/test.php

Even if I try

                    fastcgi_param SCRIPT_FILENAME $request_filename;

the directory would be /home/abc12345/html/abc12345/test.php

What is the correct configuration for fastcgi_param to escape the ../html/abc12345/..?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 2024-五一综合模拟赛
    • ¥15 下图接收小电路,谁知道原理
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭