Mac OS 安装php7.4

2022/7/1 1:19:30

本文主要是介绍Mac OS 安装php7.4,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

安装homebrew方法(若已经安装,忽略)

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

通过 brew 安装

brew install php@7.4

刷新php连接

brew link php@7.4

查看php版本

php -v

查看PHP的服务

brew services list
# 两个PHP版本
php@7.1 stopped       
php@7.2 started jason /Users/jason/Library/LaunchAgents/homebrew.mxcl.php@7.2.plist

停止老的PHP版本,启用新的php版本

# 停止老版本
brew services stop php@7.2
# 启动新的版本
brew services start php@7.4

安装

brew brew-php-switcher install

基本使用

brew-php-switcher +版本号

brew-php-switcher usage: brew-php-switcher version [-s|-s=*] [-c=*] version one of: 7.0,7.1,7.2,7.3 -s skip change of mod_php on apache -s=* skip change of mod_php on apache or valet restart i.e (apache|valet,apache|valet) -c=* switch a specific config (apache|valet,apache|valet

如切换7.2版本

brew-php-switcher 7.2

Switching to php@7.2 Switching your shell Unlinking /usr/local/Cellar/php@5.6/5.6.38... 25 symlinks removed Unlinking /usr/local/Cellar/php@7.2/7.2.18... 0 symlinks removed Unlinking /usr/local/Cellar/php/7.3.5... 0 symlinks removed Linking /usr/local/Cellar/php@7.2/7.2.18... 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.2/bin:$PATH"' >> ~/.bash_profile echo 'export PATH="/usr/local/opt/php@7.2/sbin:$PATH"' >> ~/.bash_profile

按照以上提示修改 环境变量并且

source ~/.bash_profile

生效之后

执行php -v; 控制台php命令生效(cli)

php -v; PHP 7.2.18 (cli) (built: May 22 2019 00:08:35) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.18, Copyright (c) 1999-2018, by Zend Technologies

执行php-fpm -v;

php-fpm -v; PHP 7.2.18 (fpm-fcgi) (built: May 22 2019 00:08:38) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.18, Copyright (c) 1999-2018, by Zend Technologies


                   

这篇关于Mac OS 安装php7.4的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程