本文作者:DurkBlue

phpstudy nginx配置tp5

phpstudy nginx配置tp5摘要: 修改vhosts.conf文件,选择对应站点的配置文件server {        listen     ...

修改vhosts.conf文件,选择对应站点的配置文件


phpstudy nginx配置tp5 第1张


server {

        listen        80;

        server_name  xxxmall; #网站域名,对应phpstudy“网站”中设置的

        root  "D:/phpstudy_pro/WWW/xxxmall/public"; #站点对应项目的入口文件

        location / {

            index admin.php index.html index.htm index.php admin.php;

            #autoindex  on;

             if (!-e $request_filename){

                 rewrite  ^(.*)$  /index.php?s=/$1  last;#这里指定入口文件,index.php入口文件,

             }

             if (!-e $request_filename){

                 rewrite  ^(.*)$  /admin.php?s=/$1  last;#如果项目中是多入口,则增加这里的代码,admin.php是你的入口文件

             }

 

        }

      #以下为nginx(php/fastcgi)的PATH_INFO配置

      location ~ \.php(.*)$ {

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_split_path_info ^((?U).+.php)(/?.+)$;

fastcgi_param PATH_INFO $fastcgi_path_info;

fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

    }

}

注意事项:1.Nginx的路径符号只能用/,反斜杠无法解析2.每一行结束符号用;不加会报错


nginx配置简要说明:


1.PATH_INFO为cgi的标准。Nginx默认不支持PATHINFO,需要配置才能使用。PATH_INFO可代替rewrite实现伪静态页面,tp使用PATHINFO作为路由载体。


2.cgi在web服务器接收1个请求时会fork新的进程处理,fastcgi用tcp方式跟远程机子上的进程。

此篇文章由DurkBlue博客申请发布,转载吧请注明来处
文章投稿或转载声明

来源:DurkBlue版权归原作者所有,转载请保留出处。本站文章发布于 2020-05-25
温馨提示:文章内容系作者个人观点,不代表DurkBlue博客对其观点赞同或支持。

赞(0)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏

阅读
分享

发表评论取消回复

快捷回复:
AddoilApplauseBadlaughBombCoffeeFabulousFacepalmFecesFrownHeyhaInsidiousKeepFightingNoProbPigHeadShockedSinistersmileSlapSocialSweatTolaughWatermelonWittyWowYeahYellowdog

评论列表 (暂无评论,2237人围观)参与讨论

还没有评论,来说两句吧...