apache fastcgi中FcgidInitialEnv配置

apache的主目录下有两个php应用(一个应用放在了子目录weixin下)

/weixin
    index.php
index.php
script1.php

现在有一个需求是的主目录下不同的目录使用不同的php版本
但是发现不能在directory中使用FcgidInitialEnv配置
下边是不行的

<directory "D:/Program Files/wamp/www/weixin" >
    FcgidInitialEnv PHPRC "D:/Program Files/wamp/bin/apache/apache2.4.9/bin" 
    FCGIWrapper "D:/Program\ Files/wamp/bin/php/php7.1.5/php-cgi.exe" .php 
</directory>

这是可以的

FcgidInitialEnv PHPRC "D:/Program Files/wamp/bin/apache/apache2.4.9/bin" 
<directory "D:/Program Files/wamp/www/weixin" >
    FCGIWrapper "D:/Program\ Files/wamp/bin/php/php7.1.5/php-cgi.exe" .php 
</directory>

但是这样就只能使用一个ini文件了。不能使用virtual host的方式配置,因为两个应用必须都在80端口且域名只有一个。

阅读 6.5k
1 个回答

不设置PHPRC环境变量,php会自动加载php-cgi.exe所在目录中的php.ini配置文件,只要把对应版本的php.ini配置文件放到对应的php-cgi.exe所在目录即可。

你那种方式无法实现,fcgid文档里面早有相关说明,引用如下,可供参考。

Certain settings or other concepts that depend on the virtual host, such as FcgidInitialEnv or process classes, distinguish between virtual hosts only if they have distinct server names.In the case of FcgidInitialEnv, if two virtual hosts have the same server name but different environments as defined by FcgidInitialEnv, the environment used for a particular request will be that defined for the virtual host of the request that caused the FastCGI process to be started.
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题