PHP4/PHP5 and htaccess

PHP4/PHP5 and htaccess

Posted by: richbl
Posted on: 2007-02-01 23:08:00

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.

Re: PHP4/PHP5 and htaccess

Posted by: Raz2133
Posted on: 2007-02-01 23:30:00

In reply to:

Here's what I have in the .htaccess:


Try this in your directory level .htaccess file;

for PHP5...

AddHandler php5-cgi .php

for PHP4...

AddHandler php-cgi .php


Mark

Re: PHP4/PHP5 and htaccess

Posted by: misterhaan
Posted on: 2007-02-02 06:57:00

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

Re: PHP4/PHP5 and htaccess

Posted by: richbl
Posted on: 2007-02-02 21:03:00

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.

Re: PHP4/PHP5 and htaccess

Posted by: Raz2133
Posted on: 2007-02-02 22:46:00

In reply to:

Thanks. Right on the mark.


Cool, I am glad that worked for you.

In reply to:

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


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

Re: PHP4/PHP5 and htaccess

Posted by: Mousee
Posted on: 2007-02-03 05:08:00

In reply to:


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/


That's been my experience as well, and in fact, bad things WILL happen if you try to call php outside of it.

Re: PHP4/PHP5 and htaccess

Posted by: richbl
Posted on: 2007-02-03 21:38:00

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.

Tags: htaccess redirecthtaccess filephp5whereisphpinfophp4dhusrcrucialoptions execcgigallery 1test scriptappropriatelyscripts