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

I have read this topic: Running php4 and php5 along side each other

There, the issue is handling two different generations of PHP (PHP 4 vs PHP 5), but what I need is to make all but one of my server accounts work under 5.3 and just a single domain under 5.2.

I cannot make this through Apache models, and the answer from http://stackoverflow.com/questions/524508/how-can-one-run-multiple-versions-of-php-5-x-on-a-development-lamp-server does not apply since in my case I can't use a different port - this is a regular website on the same server.

share|improve this question
1  
Why do you need two different PHP versions on a single website? –  Nathan C Jul 4 '13 at 12:27
    
Can you use one PHP version via CGI? –  SvW Jul 4 '13 at 12:30
    
i need to have tow versions of php for intsall osdate 2.5 –  Islam Baraka Jul 4 '13 at 13:45
    
Serious deployments (a.k.a. not-PHP applications) quite often require different versions of interpreter and libraries in a shared hosting configuration, nothing weird. –  fsoppelsa Jul 4 '13 at 15:51

2 Answers 2

up vote 3 down vote accepted

You can still use the answer in http://stackoverflow.com/questions/524508/how-can-one-run-multiple-versions-of-php-5-x-on-a-development-lamp-server; you just need to add a way to redirect that traffic to the other port. Here's how:

You set up a separate apache instance with PHP 5.2, and you set it to listen to port 8080.

On your regular apache, you change the VirtualHost for that one domain so that it now contains a reverse proxy to the 5.2 apache. Example:

<VirtualHost *:80>
   Servername php52.example.com
   ProxyPass / http://yourservername.example.com:8080/
   ProxyPassReverse / http://yourservername.example.com/
</VirtualHost> 

That way, your original apache instance will accept all traffic to all websites on your server. But requests to this one particular domain will be transparently forwarded to the other instance without the user on the other side of the browser knowing it.

share|improve this answer
    
Will be WP (wordpress) work in such case? –  ALex_hha Jul 4 '13 at 15:23
    
I see no reason why it shouldn't. –  Jenny D Jul 5 '13 at 8:22
    
WP is very sensitive to changing of url, even port name. If you change url from site.example.com to site.example.com:8080 the WP wouldn't work. Other the most common CMS like - Drupal, Joomla, Magento is less sensitive, as far as I know –  ALex_hha Jul 5 '13 at 8:50
    
Given that, I can make no guarantees - but the point here is that you should not change the URL; the proxy setup is specifically so you can keep the old URL even though the server is in fact running on another port. But we're now getting onto a territory that I'm less familiar with. –  Jenny D Jul 5 '13 at 9:08

I just used cgi for such case

<VirtualHost *:80>
    Servername site.example.net
    ScriptAlias /php-fastcgi/ /usr/local/php-5.2.17/bin/

    AddHandler php-fastcgi .php
    AddType application/x-httpd-php .php
    Action php-fastcgi /php-fastcgi/php-cgi
...
</VirtualHost>
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.