macOS Monterey 下安装 PHP7.1及更早版本

1,363 阅读1分钟

添加仓库

~ » brew tap shivammathur/php

验证仓库

~ » brew search php

==> Formulae
brew-php-switcher ✔                      phpstan
php                                      phpunit
php-code-sniffer ✔                       shivammathur/php/php
php-cs-fixer ✔                           shivammathur/php/php@5.6
php-cs-fixer@2                           shivammathur/php/php@7.0
php@7.1                                  shivammathur/php/php@7.1
php@7.2                                  shivammathur/php/php@7.2
php@7.3                                  shivammathur/php/php@7.3
php@7.4 ✔                                shivammathur/php/php@7.4 ✔
php@8.0 ✔                                shivammathur/php/php@8.0 ✔
phpbrew                                  shivammathur/php/php@8.2
phplint                                  pcp
phpmd                                    pup
phpmyadmin

安装旧版本

~ » brew install shivammathur/php/php@7.1

切换新版本

~ » brew-php-switcher 7.1
Switching to php@7.1
Switching your shell
Unlinking /usr/local/Cellar/php@7.1/7.1.33_4... 0 symlinks removed.
Unlinking /usr/local/Cellar/php@7.4/7.4.27... 25 symlinks removed.
Unlinking /usr/local/Cellar/php@8.0/8.0.14... 0 symlinks removed.
Linking /usr/local/Cellar/php@7.1/7.1.33_4... 25 symlinks created.

If you need to have this software first in your PATH instead consider running:
  echo 'export PATH="/usr/local/opt/php@7.1/bin:$PATH"' >> ~/.zshrc
  echo 'export PATH="/usr/local/opt/php@7.1/sbin:$PATH"' >> ~/.zshrc
You will need sudo power from now on
Switching your apache conf
Password:
Restarting apache
All done!

~ » php -v
PHP 7.1.33 (cli) (built: Nov 24 2021 20:07:53) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.1.33, Copyright (c) 1999-2018, by Zend Technologies