Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

The mod_php configuration by default for most linux distributions will be in the apache directory under conf.d/ and/or mods-available/ (for example: /etc/apache2/conf.d/php5.conf or /etc/apache2/mods-available/mod-php5) which is where the handler is being defined globally to the servers scope.

You will either have to alter your configuration to enable php5/php4 on a per vhost basis or define a different extension in the global server scope such as .php4 for the php4 handlers, depending on how many vhosts you have this may or may not be attractive.

share|improve this answer

You could use ScriptAlias along with Action - I've done a write up a while back on doing this here: http://tales.itnobody.com/2009/05/running-parallel-versions-of-php-part-2.html

The gist of what you'd end up with:

ScriptAlias /php5.3 /path/to/php/bin
Action application/php5.3 /php5.3/php-cgi
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.