简体   繁体   English

针对apache虚拟主机的不同“LoadModule php5_module”指令

[英]Different “LoadModule php5_module” instruction for apache's virtual hosts

I have apache2 and php5.2 installed as module in httpd.conf: 我在httpd.conf中安装了apache2和php5.2作为模块:

LoadModule php5_module "c:/php/php5apache2_2.dll"
PHPIniDir "C:/php/"

Also I have php5.3 in C:/php53 folder. 我在C:/ php53文件夹中有php5.3。

Is it possible to use different modules for different virtual hosts? 是否可以为不同的虚拟主机使用不同的模块?

For now I have to change LoadModule and PHPIniDir instructions and restart apache. 现在我必须更改LoadModule和PHPIniDir指令并重新启动apache。

I'm pretty sure you can not load two versions of PHP into apache at the same time. 我很确定你不能同时将两个版本的PHP加载到apache中。 However it is possible to run two different version of PHP using mod_fcgid instead. 但是,可以使用mod_fcgid运行两个不同版本的PHP。

I don't have a Windows machine right now so I cant verify that this works. 我现在没有Windows机器,所以我无法验证这是否有效。 Anyhow I found some instructions how to setup FastCGI and PHP on windows from here http://fuzzytolerance.info/blog/apache-mod_fcgid-and-php-on-windows/ 无论如何,我从这里找到了一些如何在Windows上设置FastCGI和PHP的说明http://fuzzytolerance.info/blog/apache-mod_fcgid-and-php-on-windows/

There is one exception if you want to run different version. 如果要运行不同的版本,则有一个例外。 You should not add the FCGI stuff in the global section but to each VirtualHost section instead 您不应该在全局部分添加FCGI内容,而是添加到每个VirtualHost部分

It should look something like this: 它应该看起来像这样:

<VirtualHost *:80>
  ServerName site1
  ServerAdmin admin@site1
  DocumentRoot "c:/www/site1"

  <Directory "c:/www/site1/web">
    Options +ExecCGI
    AllowOverride All

    ## FastCGI stuff
    AddHandler fcgid-script .php
    FcgidInitialEnv PHPRC "c:/php52"
    FcgidWrapper "c:/php52/php-cgi.exe" .php
    AddType application/x-httpd-php .php

    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

Then set FcgidInitialEnv PHPRC so the directory where php.ini is located and FcgidWrapper to the php-cgi.exe file for that PHP version. 然后将phpgidInitialEnv PHPRC设置为php.ini所在的目录,并将FcgidWrapper设置为该PHP版本的php-cgi.exe文件。

You have to repeat this step for all VirtualHost you want to run PHP. 您必须为要运行PHP的所有VirtualHost重复此步骤。 But now you can customize the PHPRC path and executable for each host so it is possible to run different versions and have them use different configurations. 但是现在您可以为每个主机自定义PHPRC路径和可执行文件,以便可以运行不同的版本并让它们使用不同的配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM