mac brew 无法找到php7.2 如何安装php7.2

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])
相关推荐
zm2 小时前
TCP 粘包
服务器·网络·php
Le_ee6 小时前
sqli-labs靶场第七关——文件导出注入
数据库·sql·网络安全·php·sql注入·sqli—labs
zm7 小时前
UDP 多点通信
开发语言·php
*neverGiveUp*8 小时前
PHP基础知识
开发语言·php
绵山介子推13 小时前
IP地址、端口、TCP介绍、socket介绍、程序中socket管理
网络协议·tcp/ip·php·嵌入式软件
sadoshi14 小时前
phpstudy的Apache添加AddType application/x-httpd-php .php .php5配置无效的处理方式
开发语言·php·apache
s_little_monster21 小时前
【Linux】socket网络编程基础
linux·运维·网络·笔记·学习·php·学习方法
筱宇***1 天前
Mac的web服务器
mysql·nginx·macos·php
iangyu2 天前
【windows server脚本每天从网络盘复制到本地】
开发语言·windows·php
YUJIANYUE2 天前
PHP黑白胶卷底片图转彩图功能 V2025.05.15
php