Home >Backend Development >PHP Problem >How to change php version under mac
The method to change the php version under mac is: first create a new [.bas_profile] file; then enter [export PATH=/Applications/MAMP/bin/php/php7.2.7/bin:$PATH in the new file ]; Finally, just reload the environment variables.
The operating environment of this article: macos x system, php 7.2.7, macbook pro computer.
The specific method to modify the default version of php on a mac computer is:
First create a .bas_profile file and edit it
vim ~/.bash_profile
Then enter the php version you want in it
export PATH=/Applications/MAMP/bin/php/php7.2.7/bin:$PATH #/Applications/MAMP/bin/php/php7.2.7/bin是我的php版本路径
Finally save and reload the environment variable
source ~/.bash_profile
Problems:
The ~/.bash_profile file was modified as above and found to be invalid, and the prompt zsh: command not found: homestead Then it must be because zsh is installed, because ~/.bash_profile will not be executed when zsh is installed. The solution is as follows:
Open vim ~/.zshrc and configure the environment variables you want to configure into this file
Open vim ~/.zshrc and add source ~/.bash_profile, like this The environment variables configured in ~/.bash_profile are also valid
Related recommendations:php video tutorial
The above is the detailed content of How to change php version under mac. For more information, please follow other related articles on the PHP Chinese website!