Mac M1 安装php5.6

查询php

% brew search php
==> Formulae
brew-php-switcher     php-cs-fixer          php@7.3               phplint               phpstan
php                   php-cs-fixer@2        php@7.4               phpmd                 phpunit
php-code-sniffer      php@7.2               phpbrew               phpmyadmin
==> Casks
eclipse-php                                             phpstorm

发现没有php5.6

% brew tap shivammathur/php
==> Tapping shivammathur/php
Cloning into '/opt/homebrew/Library/Taps/shivammathur/homebrew-php'...
remote: Enumerating objects: 5779, done.
remote: Counting objects: 100% (716/716), done.
remote: Compressing objects: 100% (100/100), done.
remote: Total 5779 (delta 634), reused 687 (delta 614), pack-reused 5063
Receiving objects: 100% (5779/5779), 705.32 KiB | 273.00 KiB/s, done.
Resolving deltas: 100% (4367/4367), done.
Tapped 8 formulae (57 files, 1MB).

再次查看

% brew search php
==> Formulae
brew-php-switcher           php@7.3                     phpstan                     shivammathur/php/php@7.2
php                         php@7.4                     phpunit                     shivammathur/php/php@7.3
php-code-sniffer            phpbrew                     shivammathur/php/php        shivammathur/php/php@7.4
php-cs-fixer                phplint                     shivammathur/php/php@5.6    shivammathur/php/php@8.1
php-cs-fixer@2              phpmd                       shivammathur/php/php@7.0
php@7.2                     phpmyadmin                  shivammathur/php/php@7.1
==> Casks
eclipse-php                                             phpstorm

发现已经有了php5.6

安装

brew install shivammathur/php/php@5.6

添加环境变量

# 终端
vim ~/.zshrc
 
 
# 新增
export PATH="/opt/homebrew/opt/php@5.6/bin:$PATH"
export PATH="/opt/homebrew/opt/php@5.6/sbin:$PATH"
 
 
# 终端 刷新 ~/.zshrc
source ~/.zshrc

查看php

% php -v
PHP 5.6.40 (cli) (built: May 13 2021 23:04:15) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

tips,建议brew源使用腾讯源,其他源容易出问题。

posted @ 2021-06-04 16:36  TBHacker  阅读(1328)  评论(0编辑  收藏  举报