2

Is there any way I could have php 4 and 5 installed in the same server, while keeping the same ".php" extension for both, and making it so only a specific folder (+subfolders) in the server run under php4?

I have CentOS 5.5 x64 with whm/cpanel, so I can install both with EasyApache, that part is not an issue.

Reason I want this is to keep an old script working; it's encoded with Zend and upgrading to php 5.3.x breaks it, it will only work on 5.2 (or 4.x), as it needs to be re-encoded if I am to run it on 5.3 (not an option). Decoding it didnt work quite well either, so I think the php4/5 approach would be a working solution, if I could restrict 4 to a folder and not have to change the extensions (obviously the script would fail with ".php4" because of hard-coded paths and filenames).

my current php.conf, handled by SuPHP

# SuPHP configuration for PHP5
LoadModule suphp_module modules/mod_suphp.so
suPHP_Engine on
AddType application/x-httpd-php5 .php5 .php .php3 .php2 .phtml
<Directory />
    suPHP_AddHandler application/x-httpd-php5
</Directory>

# SuPHP configuration for PHP4
AddType application/x-httpd-php4 .php4
<Directory />
    suPHP_AddHandler application/x-httpd-php4
</Directory>
hikari
  • 143

1 Answers1

1

According to the Apache documentation, AddHandler/AddType can be used in a directory context which means you should be able to simply do something like the following in the Apache config:

LoadModule php5_module modules/libphp5.so
LoadModule php4_module modules/libphp4.so

AddHandler php5-script .php
AddType    text/html .php

<Directory /home/somedir>
     AddHandler x-httpd-php4 .php
</Directory>

Note that depending on your installation you may have slightly different setup lines for php4/5 (check your existing config). If you already have php4 and 5 setup then you'd just need the entry.

uesp
  • 3,404