在apache 2.2中的虚拟主机上运行不同的PHP版本

时间:2012-08-12 13:09:41

标签: php apache virtual hosts

如何在所有虚拟主机中配置Apache 2.2服务器以使用PHP 5.3,但运行PHP 4.4的虚拟主机除外?我有所有的php和.dll文件。

1 个答案:

答案 0 :(得分:6)

http://gggeek.altervista.org/2007/07/21/running-multiple-php-versions-on-a-single-apache-install/

在本文的中间,您可以找到示例VHost配置:

# Port-based virtual hosting: every php install uses a vhost on a different port
Listen 8447
Listen 8423

### BASE virtualhost
### set up the main php version we're using
<VirtualHost *:80>
    LoadModule php5_module "E:/php5/php5apache2_2.dll"
    PHPIniDir "E:/php5"
    php_value extension_dir "E:/php5/ext/"
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
</VirtualHost>

<VirtualHost *:8447>
    # it would be handy to use php_value directives, but CGI versions of php     will not grok them,
    # so we rely on different php.ini
    SetEnv PHPRC "E:/php4/"
    ScriptAlias /php447/ "E:/php4/"
    Action application/x-httpd-php447 "/php447/php.exe"
    AddType application/x-httpd-php447 .php .inc
    # apache 2.2 denies access to the php cgi executable, unless it is explicitly granted
    <Directory "E:/php4/">
      <Files "php.exe">
        Allow from all
      </Files>
    </Directory>
</VirtualHost>

<VirtualHost *:8423>
    SetEnv PHPRC "E:/php423/"
    ScriptAlias /php423/ "E:/php423/"
    Action application/x-httpd-php423 "/php423/php.exe"
    AddType application/x-httpd-php423 .php .inc
    <Directory "E:/php423/">
      <Files "php.exe">
        Allow from all
      </Files>
    </Directory>
</VirtualHost>