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方式跟遠程機子上的進程。

 

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