Windows nginx+php-cgi开发环境搭建

  

 

php-fpm只支持Unix-like OS,不支持Windows,Windows可使用php-cgi此cgi进程管理器替代php-fpm

 

比如Apache mod_fcgid 可以用来替代 mod_cgi 和 mod_cgid,具有管理和维持PHP-CGI进程数目的功能.

ApacheLounge提供有Windows上的mod_fcgid二进制包:

http://www.apachelounge.com/download/

如果你是搭配IIS使用,则需要PHP Manager这个CGI进程管理器:

http://phpmanager.codeplex.com/

 

Windows平台, nginx可通过php附带的FastCGI守护进程对php进行管理

  1. 启动php-cgi
    php-cgi -b 127.0.0.1:9000
    start /b php-cgi -b 127.0.0.1:9000  # 后台运行

     

  2. 验证是否启动成功
    netstat -anob | findstr :9000

     

    tasklist /fi "imagename eq php-cgi.exe"



  3. 采用powershell启动

     

     

     

     


     

  4. php运行时间长了会变慢,需重启

 

nginx配置

        location ~ \.php$ {
        #    root           html;
           root d:/wamp/apache24/htdocs;
           fastcgi_pass   127.0.0.1:9000;
           fastcgi_index  index.php;
           fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
           include        fastcgi_params;
        }

 

root修改为站点根目录

$document_root由 root 指令设定,需修改fastcgi_param 为 $document_root$fastcgi_script_name 指向站点根目录

 

$document_uri 即请求path   不包含请求参数

$request_uri  === $document_uri +  "?"  +  $args

 

Example:

 

www.ibm.com/abc/index.html?a=11&b=22

$document_uri       ===           /abc/index.html

$args         ===              a=11&b=22

$request_uri            ===           /abc/index.html?a=11&b=22

 

 

nginx windows 官方连接

http://nginx.org/en/docs/windows.html

posted @ 2021-04-19 08:46  ascertain  阅读(1026)  评论(0编辑  收藏  举报