zoukankan      html  css  js  c++  java
  • Windows下nginx+php配置

    1. 首先,将 nginx.conf 中的 PHP 配置注释去掉。

    
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    
    #
    
    #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;
    
    #}
    
     
    
    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;
    
    }

    2. 这里使用的 PHP 是以 cgi 的形式,所以要启用 php-cgi,修改 php.ini,把注释去掉:

    ;cgi.fix_pathinfo=1
    
    cgi.fix_pathinfo=1

    3. 启动 php-cgi 和 nginx

    php
    D:/xampp/php/php-cgi.exe -b 127.0.0.1:9000 -c D:/xampp/php/php.ini
    nginx
    D:/nginx/start nginx

    可以看看进程里,如果 nginx 和 php-cgi 都有,那么差不多要成功了。最后,可能会出现 "No input file specified" 的问题,那么修改一下 nginx.conf :

    location ~ .php$ {
    
        #root           html;
    
        root           D:/nginx/html;
    
        fastcgi_pass   127.0.0.1:9000;
    
        fastcgi_index  index.php;
    
        #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    
        #fastcgi_param  SCRIPT_FILENAME D:/nginx/html$fastcgi_script_name;
    
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    
        include        fastcgi_params;
    
    }

    注意注释的地方,修改成下面那行,请根据你的具体文件配置路径。

    在 D:/nginx/html下编辑phpinfo文件,执行localhost/phpinfo.php即可

    转自:现代简明魔法

  • 相关阅读:
    Shell case esac 和 for
    Shell运算符:Shell算数运算符、关系运算符、布尔运算符、字符串运算符等
    杨辉三角+优化算法
    mount --bind和硬连接的区别
    Linux文件系统管理
    磁盘管理
    Linux之find文件(目录)查找
    BZOJ 3224 平衡树模板题
    NOIP 2016 滚粗记
    BZOJ 4034 线段树+DFS序
  • 原文地址:https://www.cnblogs.com/thingk/p/4647903.html
Copyright © 2011-2022 走看看