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 @   ascertain  阅读(1207)  评论(0编辑  收藏  举报
编辑推荐:
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示