Home> PHP Framework> Laravel> body text

Teach you to use the version management tool in Homestead to switch PHP versions

青灯夜游
Release: 2021-12-22 19:34:26
forward
2983 people have browsed it

How to install and switch PHP version in Homestead? The following article will introduce to you how to switch PHP versions under Homestead. I hope it will be helpful to you!

Teach you to use the version management tool in Homestead to switch PHP versions

Switch PHP version under Homestead

Laravel’s Homestead comes with PHP5.6, PHP7.0, and PHP7.1 and PHP7.2 these 4 versions. By default it runs up to version 7.2, but sometimes company needs have to switch to another version.

How to switch?

Homestead comes with a way to switch versions, as follows:

sites: - map: homestead.test to: /home/vagrant/code/Laravel/public php: "5.6"
Copy after login

However, when you execute composer in homestead, or usephp -vWhen checking the php version, the highest version is still 7.2. As a result, when composer performs a version check or updates the package, it will be updated according to version 7.2.

How to do it?

homestead comes with version management toolsupdate-alternatives

The usage is as follows:

update-alternatives --display php 查看所有 php 版本和当前版本 update-alternatives --config php 执行后,会列出当前 php 所有版本和编号,输入编号,切换到执行的版本
Copy after login

I didn’t notice that there is a file in the Homestead directory before aliases file, this file defines some commands that can be used directly in the virtual machine. For example, if you want to switch to version 7.0, just execute

php70
Copy after login

!

Related recommendations:The latest five Laravel video tutorials

The above is the detailed content of Teach you to use the version management tool in Homestead to switch PHP versions. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:learnku.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!