phpstudy nginx配置tp5

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

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方式跟远程机子上的进程。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章