PHP4/PHP5 and htaccess


#1

hello all,

I’m new to dh, and I have a question about setting up php5. My situation is that I need php4 on a majority of my domain (older Gallery 1.x app), except in a specific directory, where I need to use php5.

I know this is possible, as I’ve done it before on a slightly different system. So I must be missing some crucial step here on dh.

My understanding is that dh users have php4 and php5 already available at /usr/local/bin/php and /usr/local/php5/bin, respectively (per whereis).

I’ve also dropped a .htaccess file where I want to redirect for php5. Here’s what I have in the .htaccess:

Options +ExecCGI
AddHandler php5 .php
Action php5 /usr/local/php5/bin/php

Yet, when I attempt to run a test script (call to phpinfo()), the script fails.

Scripts above the .htaccess redirect appropriately call php4.

What am I missing here?

Thanks much.


#2

Try this in your directory level .htaccess file;

for PHP5…

[color=#0000CC]AddHandler php5-cgi .php[/color]

for PHP4…

[color=#0000CC]AddHandler php-cgi .php[/color]

Mark


Save [color=#CC0000]$50[/color] on DreamHost plans using [color=#CC0000]PRICESLASH[/color] promo code (Click for DreamHost promo code details)


#3

whatever you put in action will be using your DOCUMENT_ROOT as if it were root. so when you say /usr/local/php5/bin/php, it actually means /home/username/domain.tld/usr/local/php5/bin/php


#4

Thanks. Right on the mark.

So why doesn’t the Action php5 /usr/local/php5/bin/php work, as I’ve pathed this to the correct binary?

Time to brush up on my htaccess scripting…

Thanks again.


#5

Cool, I am glad that worked for you.

I think misterhaan was correct when he said the path you use for the action directive is referenced from DOCUMENT_ROOT, which will be /home/username/domain.tld/

Mark


Save [color=#CC0000]$50[/color] on DreamHost plans using [color=#CC0000]PRICESLASH[/color] promo code (Click for DreamHost promo code details)


#6

[quote]
I think misterhaan was correct when he said the path you use for the action directive is referenced from DOCUMENT_ROOT, which will be /home/username/domain.tld/[/quote]
That’s been my experience as well, and in fact, bad things WILL happen if you try to call php outside of it.


#7

Ahhh… brain just clicked on: the Action command is not relative to root (/), but DOCUMENT_ROOT. That explains it.

Strange how you read over something several times thinking “yeah, so?” and then brain fires up and pulls up the shade… and the world is logical and cool again…

Thanks.