How can I override mod-php5's .php mapping to php4-cgi per VirtualHost or Directory?

Posted by geocoo on Server Fault See other posts from Server Fault or by geocoo
Published on 2012-04-10T17:09:11Z Indexed on 2012/04/10 17:31 UTC
Read the original article Hit count: 351

Filed under:
|
|

I am running Debian Linux with apache2 and libapache2-mod-php5 5.3.3-7.

I have one VirtualHost which requires php4. So I researched and compiled php4-cgi.

However, I cannot seem to:

  1. Override mod-php5's mapping of .php in that vhost (or even globally, without disabling php completley).
  2. Even find where that mapping is made, in hope of disabling it and enabling mod-php5 or php4-cgi per vhost.

This is my php4-cgi mapping (Inside the one php4 vhost):

ScriptAlias /php4 /usr/local/php4/bin

<Directory /usr/local/php4/bin>
  Options +ExecCGI +FollowSymLinks
</Directory>

<Directory /www/test>
  AddHandler php4-cgi-script .php
  Action php4-cgi-script /php4/php
  Options +ExecCGI
</Directory>

This does not work, mod-php5 still runs all .php files in that vhost/directory. If I change the file extension in the AddHandler above from .php to .php4, then .php4 files do run php4-cgi as expected, but I can't change all the files in the app to .php4.

I thought maybe I could disable the mod-php5's mapping in my vhost or directory, then do my cgi-config (as above) but many combinations of these in different contexts did not work:

RemoveHandler .php
RemoveType .php
php_flag engine off (this seems to even disable my php4-cgi so that wont work)

The only other place I can find any mapping is in /etc/mime.types, but commenting out the relevant lines and restarting apache2 does not affect mod-php5's .php mapping.

I have searched as much as I can, it is now a mystery to me.

Any help or direction would be greatly appreciated.

© Server Fault or respective owner

Related posts about apache2

Related posts about php5