How to quickly switch between multiple PHP versions on mac os

黄舟
Release: 2023-03-06 12:36:01
Original
3699 people have browsed it

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
Copy after login

2. Install multiple Version of PHP

brew
install

php53

brew
install

php54
Copy after login

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
Copy after login

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
Copy after login

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
Copy after login

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
Copy after login

You can switch through the following command

brew-php-select
Copy after login

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
Copy after login

2. Install the switching tool

# brew install php-version
# source $(brew --prefix php-version)/php-version.sh
Copy after login

3. View all currently installed versions

# php-version
Copy after login

4. Switch versions

# php-version 5.6.5
Copy after login

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

Related labels:
source:php.cn
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
Popular Tutorials
More>
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!