Windows+Nginx+Mysql+PHP安裝

Nginx部分:

安裝......

①打開Nginx對php的支持,去掉#注釋;

#location ~ \.php$ {

#? ? root? ? ? ? ? html;

#? ? fastcgi_pass? 127.0.0.1:9000;

#? ? fastcgi_index? index.php;

#? ? fastcgi_param? SCRIPT_FILENAME? /scripts$fastcgi_script_name;

#? ? include? ? ? ? fastcgi_params;

#}

②修改語句

修改前

fastcgi_param? SCRIPT_FILENAME? /scripts$fastcgi_script_name;

修改后

fastcgi_param? SCRIPT_FILENAME? $document_root$fastcgi_script_name;

③添加index.php

location / {

root? html;

index? index.html index.htm inde.php;

}

PHP部分:

安裝......

① 修改php文件夾下php.ini-development文件,將文件名修改為php.ini;

② 打開extension_dir = "ext"并修改為:

extension_dir = "./ext"

③ 打開php_mysql和php_mysqli擴展

extension=php_mysql.dll

extension=php_mysqli.dll

④ PHP的啟動與關(guān)閉

cmd命令

啟動:php-cgi.exe? -b? 127.0.0.1:9000 -c? php.ini

關(guān)閉:taskkill /F /IM php-cgi.exe > nul

Mysql部分:

安裝......


Nginx對path_info的支持

①第一種,通用

location ~ .php($|/) {

? ? set $script $uri;

? ? set $path_info "";

? ? if ($uri ~ "^(.+.php)(/.+)") {

set $script $1;

set $path_info $2;

}

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$script;

fastcgi_param SCRIPT_NAME $script;

fastcgi_param PATH_INFO $path_info;

include fastcgi.conf;

}

②新版本支持,使用fastcgi_split_path_info指令設(shè)置PATH_INFO

location ~ \.php { #去掉$

fastcgi_split_path_info ^(.+\.php)(.*)$;? ? #增加這一句

fastcgi_param PATH_INFO $fastcgi_path_info;? ? #增加這一句

fastcgi_pass? 127.0.0.1:9000;

fastcgi_index? index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include? ? ? ? fastcgi_params;

}

③通過rewrite方式代替php中的PATH_INFO

location / {

if (!-e $request_filename){

rewrite ^/(.*)$ /index.php?s=/$1 last;

}

}

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容