开发者

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 开发者_StackOverflow中文版that possible? No xampp solution please.

Thanks


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


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.


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>


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜