将 Laravel Homestead v7.0.1 与 php 7.2 更改为 php 7.1
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47849825/
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 Laravel Homestead v7.0.1 with php 7.2 to php 7.1
提问by karmendra
What are the steps to downgrade the php version to 7.1 and make it default on latest Homestead 7, Homestead 7 comes with php version 7.2 as default.
将 php 版本降级到 7.1 并使其在最新的 Homestead 7 上默认的步骤是什么,Homestead 7 默认带有 php 版本 7.2。
There are a number of dev sites on my homestead I want everything to run on 7.1 by default, if I need 7.2 then I will use the following in my homestead yaml
我的宅基地上有许多开发站点,我希望默认情况下所有内容都在 7.1 上运行,如果我需要 7.2,那么我将在我的宅基地 yaml 中使用以下内容
sites:
- map: homestead.test
to: /home/vagrant/Code/homestead/public
php: "7.2"
回答by karmendra
I think I have a better solution, to switch the php version in Homestead (I am using version 8 currently) running following lines of code switches the default php version.
我想我有一个更好的解决方案,在 Homestead(我目前使用版本 8)中切换 php 版本,运行以下代码行切换默认的 php 版本。
sudo update-alternatives --set php /usr/bin/php7.1
sudo update-alternatives --set phar /usr/bin/phar7.1
sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.1
sudo update-alternatives --set phpize /usr/bin/phpize7.1
sudo update-alternatives --set php-config /usr/bin/php-config7.1
Above line will switch the php version from any version to version 7.1 (Homestead 8 comes with php 7.3 by default).
上面这行会将 php 版本从任何版本切换到 7.1 版本(Homestead 8 默认自带 php 7.3)。
Do remember to reload web-server (apache or nginx) after making this change.
请记住在进行此更改后重新加载网络服务器(apache 或 nginx)。
回答by Denes Papp
You can simply run sudo update-alternatives --config php
and choose from the list like this:
您可以简单地运行sudo update-alternatives --config php
并从列表中进行选择,如下所示:
You should then change the defaults for phar
, phar.phar
, phpize
, php-config
the same way you did for php
然后您应该更改phar
, phar.phar
,的默认值phpize
,php-config
与您所做的相同php
回答by joepferguson
You shouldn't use older versions of Homestead if you just want to use a different version of PHP.
如果您只想使用不同版本的 PHP,则不应使用旧版本的 Homestead。
You can set each site to use PHP 7.1, that won't hurt anything. You can change the CLI version by running php71
from the command line.
您可以将每个站点设置为使用 PHP 7.1,这不会有任何伤害。您可以通过php71
从命令行运行来更改 CLI 版本。