如何在 centos6 上将 PHP 5.5 降级到 5.4 或 5.3

如何在 centos6 上将 PHP 5.5 降级到 5.4 或 5.3

我的服务器运行的是 centos 6,我最近将服务器上的 php 升级到了 5.5 版,发现我使用的 laravel 框架中的某些脚本出现了问题。我收到此错误

Parse error: syntax error, unexpected 'yield' (T_YIELD), expecting '(' in /var/www/vhosts/jpischolarship.com/httpdocs/laravel/helpers.php on line 563

经过一番研究,我发现我使用的框架有一种名为“yield”的方法,它现在是 php 5.5 中的保留关键字。

如何将当前安装的 php 降级到以前的版本?我尝试过“ yum downgrade php”,但没有成功。我得到了以下输出

Loaded plugins: fastestmirror, priorities
Setting up Downgrade Process
Loading mirror speeds from cached hostfile
epel/metalink                                            |  13 kB     00:00
 * base: s2plmirror02.prod.sdl2.secureserver.net
 * epel: dl.fedoraproject.org
 * extras: s2plmirror02.prod.sdl2.secureserver.net
 * updates: s2plmirror02.prod.sdl2.secureserver.net
base                                                     | 3.7 kB     00:00
c5-testing                                               | 3.0 kB     00:00
extras                                                   | 3.5 kB     00:00
updates                                                  | 3.5 kB     00:00
Resolving Dependencies
There are unfinished transactions remaining. You might consider running yum-comp                                                                                        lete-transaction first to finish them.
The program yum-complete-transaction is found in the yum-utils package.
--> Running transaction check
---> Package php.x86_64 0:5.3.3-22.el6 will be a downgrade
--> Processing Dependency: php-common(x86-64) = 5.3.3-22.el6 for package: php-5.                                                                                        3.3-22.el6.x86_64
--> Processing Dependency: php-cli(x86-64) = 5.3.3-22.el6 for package: php-5.3.3                                                                                        -22.el6.x86_64
---> Package php.x86_64 0:5.5.0-0.25.beta3.el6.remi will be erased
--> Finished Dependency Resolution
Error: Package: php-5.3.3-22.el6.x86_64 (base)
           Requires: php-common(x86-64) = 5.3.3-22.el6
           Installed: php-common-5.5.0-0.25.beta3.el6.remi.x86_64 (@remi-test)
               php-common(x86-64) = 5.5.0-0.25.beta3.el6.remi
           Available: php-common-5.3.3-22.el6.x86_64 (base)
               php-common(x86-64) = 5.3.3-22.el6
Error: Package: php-5.3.3-22.el6.x86_64 (base)
           Requires: php-cli(x86-64) = 5.3.3-22.el6
           Installed: php-cli-5.5.0-0.25.beta3.el6.remi.x86_64 (@remi-test)
               php-cli(x86-64) = 5.5.0-0.25.beta3.el6.remi
           Available: php-cli-5.3.3-22.el6.x86_64 (base)
               php-cli(x86-64) = 5.3.3-22.el6
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

答案1

您需要运行:

 "sudo yum downgrade php php-common php-cli"

答案2

CentOS 上采用来自 atomic repo 的 php 的不同方法。由于 atomic 上没有旧的 5.3,因此您需要不同的 repo。我使用了http://webtatic.com

安装 repo:

rpm -Uvh http://mirror.webtatic.com/yum/centos/5/latest.rpm

安装 gpg-key:

rpm --import http://repo.webtatic.com/yum/RPM-GPG-KEY-webtatic-andy

编辑原子仓库:

vi /etc/yum.repos.d/atomic.repo

为原子添加 php 排除:

[atomic]
exclude=php,php-common,php-*

编辑 webtactic 仓库:

vi /etc/yum.repos.d/webtatic.repo

更改 repo 设置:

[webtactic]
enabled=1

现在降级 php:

yum downgrade php, php-*

对我有用。

相关内容