Jebb
Jebb

Reputation: 101

How to switch PHP version back and forth?

I installed LAMP manually on Ubuntu, let's say my current version of PHP is 5.2 and I want to switch to PHP 5.3 for awhile, is that possible? No xampp solution please.

Thanks

Upvotes: 0

Views: 1612

Answers (4)

M Arfan
M Arfan

Reputation: 4575

here is the solution with .htaccess

1: Create new file
2: name with .htaccess
3: save to your root folder

To switch to PHP 4.4:

AddHandler application/x-httpd-php4 .php

To switch to PHP 5.0:

AddHandler application/x-httpd-php5 .php

To switch to PHP 5.1:

AddHandler application/x-httpd-php51 .php

To switch to PHP 5.2:

AddHandler application/x-httpd-php52 .php

To switch to PHP 5.3:

AddHandler application/x-httpd-php53 .php

To switch to PHP 5.4:

AddHandler application/x-httpd-php54 .php

Upvotes: 0

Saurabh Chandra Patel
Saurabh Chandra Patel

Reputation: 13586

for 5.2

<Directory "/var/www/">
        AddHandler application/x-httpd-php52 .php 
</Directory>

for 5.3

<Directory "/var/www/">
        AddHandler application/x-httpd-php53 .php 
</Directory>

for 5.4
<Directory "/var/www/">
        AddHandler application/x-httpd-php54 .php 
</Directory>

Upvotes: 0

Daniel Egeberg
Daniel Egeberg

Reputation: 8382

You can install them in something like /opt/php5.2 and /opt/php5.3 and then use update-alternatives to switch between the binaries.

Upvotes: 2

prodigitalson
prodigitalson

Reputation: 60413

The most hassle free way would be to run it as CGI instead of using mod_apache. Then you can run both simultaneously by simply changing handler .php with a .htaccess or in a vhost.

Upvotes: 0

Related Questions