简体   繁体   English

如何在 Ubuntu 16.04 上的 XAMPP 中安装较旧的 PHP 版本?

[英]How to install older PHP version in XAMPP on Ubuntu 16.04?

I'm trying to install Magento on my system, But it gives me an error that the PHP version that I have is newer and Magento is not supported that version.我正在尝试在我的系统上安装Magento ,但它给我一个错误,即我拥有的PHP版本较新,并且该版本不支持Magento So now I'm trying to downgrade my PHP version from XAMPP that I'm installed on Ubuntu 16.04 .所以现在我试图从我安装在Ubuntu 16.04上的XAMPP降级我的PHP版本。

Error :错误 :

PHP Version Check Your PHP version is 7.1.1. PHP 版本检查您的 PHP 版本是 7.1.1。 The required PHP version is ~5.6.5|7.0.2|7.0.4|~7.0.6.所需的 PHP 版本为 ~5.6.5|7.0.2|7.0.4|~7.0.6。 Hide detail Download and install PHP from www.php.net using this PHP Documentation.隐藏详细信息 使用此 PHP 文档从 www.php.net 下载并安装 PHP。 For additional assistance, contact your hosting provider.如需更多帮助,请联系您的托管服务提供商。

But I'm confuse how to do this.但我很困惑如何做到这一点。 Is it good to downgrade it or I've to install new PHP in XAMPP .降级它好还是我必须在 XAMPP 中安装新的PHP

I know this question is not belongs to stackoverflow, but I'm googled it and I don't get any proper output, so I post this question here.我知道这个问题不属于 stackoverflow,但我用谷歌搜索了它,但没有得到任何正确的输出,所以我在这里发布了这个问题。

There are some links that I referred :我提到了一些链接

https://askubuntu.com/questions/412467/how-can-i-install-different-versions-of-php-in-xampp https://askubuntu.com/questions/412467/how-can-i-install-different-versions-of-php-in-xampp

https://askubuntu.com/questions/109404/how-do-i-install-different-upgrade-or-downgrade-php-version-in-still-supported https://askubuntu.com/questions/109404/how-do-i-install-different-upgrade-or-downgrade-php-version-in-still-supported

https://github.com/phpbrew/phpbrew https://github.com/phpbrew/phpbrew

https://tecadmin.net/install-php5-on-ubuntu/# https://tecadmin.net/install-php5-on-ubuntu/#

These links are all about installing two or more PHP versions in Ubuntu but I'm not get how can I done it in XAMP on ubuntu 16.04.这些链接都是关于在 Ubuntu 中安装两个或更多 PHP 版本,但我不知道如何在 ubuntu 16.04 上的 XAMP 中完成它。 Please any kind of help is appreciated.请任何形式的帮助表示赞赏。

Since Ubuntu 16 comes only with PHP 7 available in its repositories, you will need to add a new repository that has previous version.由于 Ubuntu 16 的存储库中仅提供 PHP 7,因此您需要添加一个具有先前版本的新存储库。 This is the line you will need to write in console:这是您需要在控制台中编写的行:

sudo add-apt-repository ppa:ondrej/php

I would try to remove first the newest version before installing the older one.在安装旧版本之前,我会尝试先删除最新版本。 Having two different versions of php installed simply doesn't sound right.安装两个不同版本的 php 听起来不太对。

Anyway, even using this new repository, you will most likely face issues when installing other components related to php.无论如何,即使使用这个新存储库,您在安装与 php 相关的其他组件时也很可能会遇到问题。 At least for this reason, my advice is to make use of Docker.至少出于这个原因,我的建议是使用 Docker。 This approach will allow you to have different working environments on the same machine.这种方法将允许您在同一台机器上拥有不同的工作环境。 I recommend you to start by reading this article: https://www.sitepoint.com/docker-and-dockerfiles-made-easy/我建议您从阅读这篇文章开始: https : //www.sitepoint.com/docker-and-dockerfiles-made-easy/

Hope it helps!希望能帮助到你!

From php5.6 to php7.0:从 php5.6 到 php7.0:

Apache:阿帕奇:

    sudo a2dismod php5.6 ; 
    sudo a2enmod php7.0 ; 
    sudo service apache2 restart

CLI: sudo update-alternatives --set php /usr/bin/php7.0 CLI: sudo update-alternatives --set php /usr/bin/php7.0

From php7.0 to php5.6 :从 php7.0 到 php5.6

Apache:阿帕奇:

sudo a2dismod php7.0 ; 
sudo a2enmod php5.6 ;
sudo service apache2 restart

CLI:命令行界面:

sudo update-alternatives --set php /usr/bin/php5.6

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM