nginx针对一个域名多个php版本访问不同的目录

  • Post author:
  • Post category:php


test.com/test1 就会走php5.5版本

test.com/test2 就会走php5.2版本

test.com  默认走php7.0版本


    location /test1/ {
                 rewrite ^/test1/(\w+)/(\d+).html$  /test1/$1/test1.php?qh=$2 last;
                 rewrite ^/test1/(\w+)/p(\d+)/$ /test1/$1/test1.php?topage=$2 last;
                 root /web/test.com/;
        location ~ .*\.(php|php5)?$ {
                    fastcgi_pass  127.0.0.1:9000; #php5.5
                    fastcgi_index index.php;
                    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                    include fastcgi_params;
        }
    }

    location /test2/ {

        include rewrite.txt;   #因为test2的伪静态规则太多,所以把test2伪静态都写入到rewrite.txt了,直接include引用即可
        root /web/test.com/;
        location ~ .*\.(php|php5)?$ {
                    fastcgi_pass  127.0.0.1:9001;  #php5.2
                    fastcgi_index index.php;
                    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                    include fastcgi_params;
        }

   }



    location ~ .*\.(php)?$ {   #通用配置
                fastcgi_pass  127.0.0.1:9003; #php7.0
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
    }



版权声明:本文为wojiuwangla原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。