dsxd62219570 2009-02-22 10:17
浏览 63
已采纳

在Apache和NGINX之间共享PHP-CGI

I've been running most of my PHP apps on my website on a fastcgi backend, served by NGINX. I have a new application which seems pretty well integrated with Apache; it's heavily dependent on dynamically written .htaccess files, for example. I'm working on modifying it to work natively with NGINX, but that's not yet ready. In the meantime, I was going to have NGINX proxy all connections to that path straight to Apache, and let Apache handle it.

However, I'm on a memory limited VPS, and I'd rather not run one set of PHP-CGI processes for NGINX (with their own APC cache) and another for Apache (using more memory for their APC cache). Has anyone had any luck sharing PHP between the two?

mod_ fcgid doesn't appear to support using already running servers, so I tried mod_ fastcgi. This seemed to work at first, but was sucking up quite a lot of memory (committed -- it was growing, not just static). Worse, I couldn't get the DirectoryIndex line in my apache configs to work with mod_fastcgi!

I added

    AddHandler php5-fastcgi .php
    FastCgiExternalServer /var/www -host 127.0.0.1:9000

to my Apache config, and all .php pages are processed, but a path like http://example.com/foo/ doesn't server /foo/index.php! If I remove FastCgiExternalServer, then it does find the index.php, but of course just shows it as text.

I'm assuming it's because DirectoryIndex is processed after FastCgiExternalServer, but I have no idea how this can be changed.

  • 写回答

1条回答 默认 最新

  • dongzhidian3538 2009-02-22 19:33
    关注

    Problem solved. The trick was to use the following lines

    FastCGIExternalServer /var/www/fast-cgi-fake-handler -host 127.0.0.1:9000
    AddType application/x-httpd-fastphp5 .php
    Action application/x-httpd-fastphp5 /fast-cgi-fake-handler
    

    The relative path in Action + the full path in FastCGIExternalServer did it!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)