美文网首页
Windows+Nginx+Mysql+PHP安装

Windows+Nginx+Mysql+PHP安装

作者: LL1502 | 来源:发表于2017-11-29 09:53 被阅读0次

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的启动与关闭

cmd命令

启动:php-cgi.exe  -b  127.0.0.1:9000 -c  php.ini

关闭: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指令设置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;

}

}

相关文章

网友评论

      本文标题:Windows+Nginx+Mysql+PHP安装

      本文链接:https://www.haomeiwen.com/subject/mapylxtx.html