8

How can I configure Apache 2.2 server to have PHP 5.3 in all virtual hosts, except one virtual host in which to run PHP 4.4? I have all the php and .dll files.

CoursesWeb
  • 4,179
  • 3
  • 21
  • 27

1 Answers1

6

Original article explaining the solution no longer available. Replaced by Wayback Machine entry (Dec 2020) (https://web.archive.org/web/20190922142848/http://gggeek.altervista.org/2007/07/21/running-multiple-php-versions-on-a-single-apache-install/)

Example VHost configuration:

# 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>
Peter Ilfrich
  • 3,727
  • 3
  • 31
  • 35
  • 2
    don't link websites as the answers - target site may be removed and therefore there will be no answer. always type the exact answer on stack exchange sites. – tymik Dec 08 '16 at 14:23
  • 1
    Fair point, I copied the example config here for persistence. Hopefully Stackoverflow never gets removed :P – Peter Ilfrich Dec 16 '16 at 03:21
  • 1
    keep this in mind in future, please - this is one of the rules of SE for providing answers. also it would be helpful if you also described the config a little in the answer - important variables, etc. I also hope it will not get removed. – tymik Dec 18 '16 at 00:20
  • Link is no longer available. – ALZlper Dec 03 '20 at 12:11