mac brew 无法找到php7.2 如何安装php7.2
原因是升级过高版本的brew后已经不支持7.2了,但可以通过第三方工具来安装
php
brew tap shivammathur/php
brew install shivammathur/php/[email protected]
标题安装完成后会提示以下信息:
php
The php.ini and php-fpm.ini file can be found in:
/usr/local/etc/php/7.2/
[email protected] 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 [email protected] first in your PATH, run:
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.zshrc
For compilers to find [email protected] you may need to set:
export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
export CPPFLAGS="-I/usr/local/opt/[email protected]/include"
To start shivammathur/php/[email protected] now and restart at login:
brew services start shivammathur/php/[email protected]
Or, if you don't want/need a background service you can just run:
/usr/local/opt/[email protected]/sbin/php-fpm --nodaemonize
==> openjdk@11
For the system Java wrappers to find this JDK, symlink it with
sudo ln -sfn /usr/local/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk
openjdk@11 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 openjdk@11 first in your PATH, run:
echo 'export PATH="/usr/local/opt/openjdk@11/bin:$PATH"' >> ~/.zshrc
For compilers to find openjdk@11 you may need to set:
export CPPFLAGS="-I/usr/local/opt/openjdk@11/include"
==> scrcpy
At runtime, adb must be accessible from your PATH.
You can install adb from Homebrew Cask:
brew install --cask android-platform-tools
zsh completions have been installed to:
/usr/local/share/zsh/site-functions
这里面有几个重要信息:
php
// 1. php.ini 路径在
/usr/local/etc/php/7.2/
// 2. 确保已经添加环境变量
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.zshrc
// 3. 供编译器查找[email protected]需要确保以下设置
export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
export CPPFLAGS="-I/usr/local/opt/[email protected]/include"
// 4. 此时可验证php是否安装成功
$ php -v
PHP 7.2.34 (cli) (built: Mar 31 2025 08:08:00) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.34, Copyright (c) 1999-2018, by Zend Technologies
// 5. 启动、停止、重启php7.2
// 查询运行状态
$ brew services list | grep php
[email protected] started smt ~/Library/LaunchAgents/[email protected]
// 启动
$ brew services start shivammathur/php/[email protected]
==> Successfully started `[email protected]` (label: [email protected])
// 重启
$ brew services restart shivammathur/php/[email protected]
Stopping `[email protected]`... (might take a while)
==> Successfully stopped `[email protected]` (label: [email protected])
==> Successfully started `[email protected]` (label: [email protected])
// 停止
$ brew services stop shivammathur/php/[email protected]
Stopping `[email protected]`... (might take a while)
==> Successfully stopped `[email protected]` (label: [email protected])