homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

Multiple php versions
How do I use AddHandler to run multiple php versions on apache?

Msg#: 4662291 posted 11:08 am on Apr 11, 2014 (gmt 0)

I have Apache 2.4 and php 5.4 installed on Windows for development. I do not use Virtual Hosts for my projects since I tend to work on different machines and keeping the hosts file synced is a bit of a hassle, besides, typing [localhost...] works just fine for me.

I have had some problems with doing projects that required different php versions on the production server, so now I have multiple php versions installed in different directories and simply rename php/ to php54/ and php53/ to php whenever I need another version. But this is tedious, esp. when working on more than one project at a time.

I noticed on one of my client's web hosting that they allow you to set:

<FilesMatch "\.php$">
AddHandler x-httpd-php53 .php

in the htaccess. Effectively changing from php 5.2 to 5.3. Now that is a perfect solution. That way i can just set the version I need in the htaccess file on a per project basis.
But I cannot find anywhere how to set this up? Perhaps partly because I am not very proficient with Apache configurations.
Can someone explain how to set this up like this where I use php5.4 as default, and being able to switch to 5.3 and 5.5 in htaccess.



WebmasterWorld Administrator phranque us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

Msg#: 4662291 posted 11:17 am on Apr 11, 2014 (gmt 0)

someone asked a similar question here last year.

Can I run multiple versions of PHP on Apache?:
http://www.webmasterworld.com/apache/4590425.htm [webmasterworld.com]


WebmasterWorld Senior Member lucy24 us a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month

Msg#: 4662291 posted 11:33 am on Apr 11, 2014 (gmt 0)

What's the FilesMatch for? It seems redundant: "if the filename ends in .php, then use php5.3 for php files". What you want to do instead is constrain the rule to a particular directory, either by putting the rule in a <Directory> section or by a supplementary htaccess file, whichever is more convenient.

I see that I said last year what I was about to say today, so no need to repeat it ;)


Msg#: 4662291 posted 12:17 pm on Apr 11, 2014 (gmt 0)

@phranque: None of those threads really answer this question.

@lucy: You are right, the FilesMatch is redundant, I just copy/pasted it from the web hosting's website.

As I keep searching I get the feeling this is done with suphp, however that is something which does not run on Windows, so perhaps this is impossible? It seems to me the solution would be to 'define' the different handlers x-httpd-php53 and x-httpd-php55 and then just use them in htaccess as the apache docs say that AddHandler overrides any previous instances. So the question is really, can I 'define' these handlers on windows?

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved