Change Laravel Homestead v7.0.1 with php 7.2 to php 7.1

守給你的承諾、 提交于 2020-12-28 06:56:42

问题


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.

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

sites:
    - map: homestead.test
      to: /home/vagrant/Code/homestead/public
      php: "7.2"

回答1:


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.

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).

Do remember to reload web-server (apache or nginx) after making this change.


July 2020 UPDATE: In newer versions of homestead to change php version there are aliases like php71 php72 php73 etc. to easily swith between versions




回答2:


You can simply run sudo update-alternatives --config php and choose from the list like this:

You should then change the defaults for phar, phar.phar, phpize, php-config the same way you did for php




回答3:


You shouldn't use older versions of Homestead if you just want to use a different version of PHP.

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.



来源:https://stackoverflow.com/questions/47849825/change-laravel-homestead-v7-0-1-with-php-7-2-to-php-7-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!