Home > Article > Backend Development > How to quickly switch between multiple PHP versions on mac os
This article summarizes four methods for quickly switching between multiple php versions under mac os. It is very simple and practical. Friends in need can refer to it
php is to quickly build a web page The open source language that has quickly been widely accepted by everyone has developed a lot of PHP open source systems through continuous development, which meets the site needs of most current users. Since PHP was born in early 1995, there have been multiple versions, and each version belongs to a series. Most website source codes are not compatible with each other, so it is very practical to be able to quickly switch PHP versions.
Method 1
1. Add tap
brew tap josegonzalez/php
2. Install multiple Version of PHP
brew install php53 brew install php54
3. Make the switching script
mkdir -p ~/.bin/php-switch cd ~/.bin/php-switch curl -L http://www.php.cn/ > php-switch chmod +x php-switch
You need to add php-switch to PATH, you can add it in .bash_profile, so that it can be automatically loaded when booting
4. Finally, you can switch the php version through the following command
php-switch
Method 2
You can install the switching tool directly through homebrew
brew tap homebrew/dupes brew tap josegonzalez/homebrew-php brew install php-version # Homebrew (recommended) source $(brew --prefix php-version)/php-version.sh && php-version 5
After the above installation is completed, you can also switch through php-version
Method 3
Install the switching tool
npm install -g brew-php-select LoadModule php5_module /usr/local/php/libexec/apache2/libphp5.so
You can switch through the following command
brew-php-select
Method 4
Note: Requirements All PHP versions are installed by brew
1. Use brew to install PHP multi-version method
# brew install php56 # brew install php71
2. Install the switching tool
# brew install php-version # source $(brew --prefix php-version)/php-version.sh
3. View all currently installed versions
# php-version
4. Switch versions
# php-version 5.6.5
The above is the content of how to quickly switch multiple PHP versions on mac os. For more related content, please pay attention to PHP Chinese website (www.php.cn)!