Get the App
SLTechnology News&Howtos  ›  Development  › 

How to solve the problem of brew link failed to change php version

Shulou Source: shulou.com Published: 2022-06-02 16:11:55 10月03日 Update

This article mainly explains "how to solve the problem of brew link changing php version failure". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to solve the problem of brew link changing php version failure".

Problem description:

I installed three php versions through brew

Php 5.6php 7.4php 8.0

$php-v

PHP 8.0.3 (cli) (built: Mar 4 2021 20:45:17) (NTS) Copyright (c) The PHP GroupZend Engine v4.0.3, Copyright (c) Zend Technologies with Zend OPcache v8.0.3, Copyright (c), by Zend Technologies

Deactivate 8.0 to use 7.4

$brew unlink php@8.0 & & brew link php@7.4Unlinking / usr/local/Cellar/php/8.0.3... 0 symlinks removed.Linking / usr/local/Cellar/php@7.4/7.4.16... 264 symlinks created.$ php-v

Still the same version.

It's the same with my new client 8.0.3.

PHP 8.0.3 (cli) (built: Mar 4 2021 20:45:17) (NTS) Copyright (c) The PHP GroupZend Engine v4.0.3, Copyright (c) Zend Technologies with Zend OPcache v8.0.3, Copyright (c), by Zend Technologies

The middle moment has been operated.

Where is this set up less?

Analysis and solution:

You can try to install a PHP selector

Brew updatebrew upgrade

Reference documentation

Https://github.com/shivammathur/homebrew-php

Install the specified php brew install shivammathur/php/php@7.3

Link to php version brew link-- overwrite-- force php@7.3

If an error occurs

Warning: Already linked: To relink: brew unlink & & brew link

Execution

Brew unlink php@7.3brew link-overwrite-force php@7.3

Restart the service

Apache brew services restart httpdnginx brew services restart nginx

Installation result

To enable PHP in Apache add the following to httpd.conf and restart Apache: LoadModule php7_module / usr/local/opt/php@7.0/lib/httpd/modules/libphp7.so SetHandler application/x-httpd-php Finally, check DirectoryIndex includes index.php DirectoryIndex index.php index.htmlThe php.ini and php-fpm.ini file can be found in: / usr/local/etc/php/7.0/php@7.0 is keg-only, which means it was not symlinked into / usr/local Because this is an alternate version of another formula.If you need to have php@7.0 first in your PATH run: echo 'export PATH= "/ usr/local/opt/php@7.0/bin:$PATH"' > > ~ / .zshrc echo 'export PATH= "/ usr/local/opt/php@7.0/sbin:$PATH" > > ~ / .zshrcFor compilers to find php@7.0 you may need to set: export LDFLAGS= "- L/usr/local/opt/php@7.0/lib" export CPPFLAGS= "- I/usr/local/opt/php@7.0/include" To have launchd start shivammathur/php/php@7.0 now and restart at login: brew services start shivammathur/php/php@7.0Or If you don't want/need a background service you can just run: php-fpm, thank you for your reading. The above is the content of "how to solve the problem of brew link replacement php version failure". After the study of this article, I believe you have a deeper understanding of how to solve the problem of brew link replacement php version failure, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Versions questions learning content that is ideas situations documents articles more knowledge knowledge points articles results follow links analysis reference practice try Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS vpn MySQL Xiaomi Shulou Tech Info