使用 .htaccess 或 php.ini 更改服务器上的 PHP 版本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12105632/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Change PHP version on server using either .htaccess or php.ini
提问by Anri?tte Myburgh
How can I change the PHP version to 5.2 on a server using either an .htaccess of php.ini file?
如何使用 php.ini 文件的 .htaccess 在服务器上将 PHP 版本更改为 5.2?
采纳答案by Wayne Whitty
Adding
添加
AddHandler application/x-httpd-php52 .php .php5 .php4 .php3
to your .htaccess might work.
到您的 .htaccess 可能有效。
回答by Adder
I take it you want to process e.g. .php3 files with php 3.x.
我认为您想使用 php 3.x 处理例如 .php3 文件。
You can't switch between php versions like this, but you might be able to do it by setting up a proxy server that distributes the query to one of several servers (one for each PHP version).
您不能像这样在 php 版本之间切换,但您可以通过设置代理服务器将查询分发到多个服务器之一(每个 PHP 版本一个)来实现。
There might also be some apache hack that works by calling the cgi-bin mode php in FastCGI mode. See the linked answer for this.
可能还有一些 apache hack 可以通过在 FastCGI 模式下调用 cgi-bin 模式 php 来工作。请参阅链接的答案。
回答by Paul Chris Jones
According to https://www.first2host.co.uk/f/change-php-version-php-ini/, adding the following line to your php.ini file will change you to PHP version 5.2:
根据https://www.first2host.co.uk/f/change-php-version-php-ini/,将以下行添加到您的 php.ini 文件会将您更改为 PHP 5.2 版:
AddHandler application/x-httpd-php52 .php
It only works if your host is first2host though, I reckon.
我认为,它仅在您的主机是 first2host 时才有效。

