Home > Backend Development > PHP Tutorial > Switching between multiple php versions under mac (operable version)

Switching between multiple php versions under mac (operable version)

藏色散人
Release: 2023-04-07 11:08:01
forward
3807 people have browsed it

Switching between multiple php versions under mac (operable version)

Switching multiple php versions under mac (operable version)

Referenced multiple articles and carried out Test practice, summarized the following correct operation methods

Practice

Applicable version:

OS X Version:    10.12.3 (16D32)
--------
Homebrew 1.3.2
Homebrew/homebrew-core (git revision aeab0; last commit 2017-09-14)
--------
PHP Version in use:    php71 56
Copy after login

And, the premise is that you have followed php56

1.brew update

You need to update the brew software warehouse directory first

2.brew upgrade

According to In the software warehouse directory updated by the previous update, use upgrade to update all software and related dependencies. In order to ensure the correct installation of the software

Remarks:

Use doctor to print the details of the error and the installation goes smoothly. If so, there is no need to use

brew doctor
Copy after login

3.brew install php71

You need to install this php warehouse first

brew tap josegonzalez/homebrew-php
Copy after login

and then install php71

brew install php71
Copy after login

It should be noted that here you need to disassociate homebrew from php56 first, and then install php71

brew unlink php56
Copy after login

4. Install php-version

Install php-version

brew install php-version
Copy after login

Set the initialization of php-version

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

So that you can use multiple versions

php-version   
* 5.6.30
  7.1.8
➜  ~ php -version
PHP 5.6.30 (cli) (built: Sep 15 2017 14:11:24) (DEBUG)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
➜  ~ php -version                 
PHP 7.1.8 (cli) (built: Sep 15 2017 14:26:34) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
➜  ~ php-version 
  5.6.30
* 7.1.8
Copy after login

Encountered problems

Error report:

dyld: Library not loaded: /usr/local/opt/libpng/lib/libpng16.16.dylib
Referenced from: /usr/local/bin/php
Reason: Incompatible library version: php requires version 45.0.0 or later, but libpng16.16.dylib provides version 38.0.0
Abort trap: 6
Copy after login
dyld: Library not loaded: /usr/local/opt/libpng/lib/libpng16.16.dylib
  Referenced from: /usr/local/Cellar/php70/7.0.22_14/bin/php
  Reason: Incompatible library version: php requires version 48.0.0 or later, but libpng16.16.dylib provides version 45.0.0
Copy after login

In fact, the error reports are similar. They all say that there is a problem with the libpng version. There are two solutions:

1. Update libpng. If the problem cannot be solved, jump to option 2

brew upgrade libpng
Copy after login

2. Don’t use php70, use php71

No matter how you test 7.0, it won’t work, just switch to 7.1

The above is the detailed content of Switching between multiple php versions under mac (operable version). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:segmentfault.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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template