我们用brew来安装php
brew search redis 搜索redis
brew install redis 安装redis
brew list 安装的软件
brew services list 所有的启动
brew services start php 启动php
brew services stop php 关闭php
以下命名%开头的表示输入命令
- 查看本地已有的php版本
//查看当前php版本
% php -v
PHP 7.2.26 (cli) (built: Dec 18 2019 15:28:10) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.26, Copyright (c) 1999-2018, by Zend Technologies
//查看安装的php版本,发现php最新版
% brew list | grep php
php
//查找其他版本
% brew search php
==> Formulae
brew-php-switcher php-cs-fixer phplint phpstan
php ✔ php@7.2 phpmd phpunit ✔
php-code-sniffer php@7.3 phpmyadmin
==> Casks
homebrew/cask/eclipse-php homebrew/cask/netbeans-php
//安装php@7.2
% brew install php@7.2
//查看并停止当前的php服务
% brew services list
% brew services stop php
//启动php@7.2
% brew services start php@73.
Name Status User Plist
php stopped
php@7.2 started chentao /Users/chentao/Library/LaunchAgents/homebrew.mxcl.php@7.2.plist
redis started chentao /Users/chentao/Library/LaunchAgents/homebrew.mxcl.redis.plist
//切换系统的php版本
% brew unlink php
% brew link php@7.2
//检查当前系统的php版本
% php -v
PHP 7.2.26 (cli) (built: Dec 18 2019 15:28:10) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.26, Copyright (c) 1999-2018, by Zend Technologies
至此php版本切换至7.2