一、以前Mac安装php及php扩展的方式

用Mac的童鞋都知道,我们以前都是用brew install php70,brew install php71 这样来安装php的,用brew install php70-xdebug,brew install php71-redis等这样来安装php某个版本对应的扩展的,而且这样的安装方式非常方便,每个扩展都单独使用一个配置文件,放在/usr/local/etc/php/7.1/conf.d 里面(其中7.1是版本,你电脑上有可能是其他版本),如下所示:

 bruce > … > php > 7.1 > conf.d > ls -l
total 56
-rw-r--r--  1 bruce  admin   300 Dec  2  2017 ext-igbinary.ini
-rw-r--r--  1 bruce  admin    62 Dec  4  2017 ext-imagick.ini
-rw-r--r--  1 bruce  admin  4132 Dec  2  2017 ext-memcached.ini
-rw-r--r--  1 bruce  admin    78 Apr  8 10:45 ext-opcache.ini
-rw-r--r--  1 bruce  admin   292 Dec  2  2017 ext-redis.ini
-rw-r--r--  1 bruce  admin   273 Apr 11 20:48 ext-xdebug.ini
 
二、第三方维护的php tap被移动到Homebrew/core

看,用brew search php71就有提示,我以前用的这个tap:josegonzalez/php 被移动到homebrew/core了

 bruce > ~ > brew search php71
==> Formulae
php@7.1 ✔
If you meant "php71" specifically:
It was migrated from josegonzalez/php to homebrew/core.

移动的原因:homebrew在1.5版本更新时说明了将会在2018-03-31前弃用并且归档Homebrew/php这个tap,原因是Homebrew组织已经无法通过非核心公式tap的方式,去维护一个可被使用者或贡献者接受的一致性的体验及持续完整性的工作量!

什么鬼?我自己翻译的看了半天也觉得不通顺啊,但大概意思我是知道的,自己看原文吧:

https://brew.sh/2018/01/19/homebrew-1.5.0/

 By 31st March 2018 we will deprecate and archive the Homebrew/php tap. Unfortunately we have been unable to maintain an acceptable, consistent user or contributor experience and CI workload through non-core formula taps in the Homebrew organisation so we are continuing to migrate widely used formulae into Homebrew/core and encourage more niche formulae and options to be supported outside the Homebrew organisation.
 
We deprecated and archived the Homebrew/php tap and created new php and versioned php@* formulae in Homebrew/core. This completes the deprecation and archival of the last non-Homebrew/core tap for end-users. We encourage more niche formulae and options to be supported in taps outside the Homebrew organisation.
 
CI workload的CI是什么意思呢?
三、现在要怎么安装php以及php扩展?

1)怎么安装php扩展

首先我要说一下怎么安装扩展,因为发现这个问题就是因为我安装amqp扩展的时候,用brew search amqp,无法查询到类似php71-amqp这样的扩展,于是去网上搜索,发现好多人都说现在不能用brew的方式安装扩展了,要用pecl install amqp这样的方式安装,于是就去查为什么不能用brew的方式安装扩展了,查到的结果就是上面第二点提到的原因,于是我就决定用pecl来安装amqp扩展,可是我从来没用过pecl,都不知道是什么,查了一下发现pecl是“PHP Extension Community Library”,翻译一下就是php扩展库,看pecl install amqp想到pecl肯定是一个命令嘛,我电脑上没有就装一个呗,于是我就想去安装一个pecl,我先用brew查询一下有没有pecl:brew search pecl,结果查询到没有,而且出来一堆像报错一样的信息(认真看了一下其实不是报错),我就想brew怎么没法安装呢,难道要用源码包?于是去网上查,在https://pecl.php.net/ 上才发现The packaging and distribution system used by PECL is shared with its sister, PEAR. 为什么是sister?不是brother?疑惑中。。。然后我又双叒叕去查pear是什么东西,我觉得应该不会是我喜欢吃的雪梨,一查果然不是雪梨,而是“PHP Extension and Application Repository” 翻译一下就是PHP扩展及应用库,现在知道了PEAR是PECL的姐姐,可是我要安装的是PECL啊,到底要怎么安装???网上找了半天,跟这个兄弟一样没找着怎么安装pecl:
 
我要在我的系统中安装swoole扩展,官网提供的是用pecl方式安装,可是我输入pecl install swoole之后系统说没找到该命令,然后我百度了半天也没找到怎么在linux下安装pecl这个东西,请问这是个什么东东,如何安装他?
 
其实我现在已经知道,要使用pecl命令,只要安装pear就行了,但是查了半天,也没人说安装了pear就能使用pecl命令,后来看了好多答案都提到pear,我就准备安装个pear,于是brew search pear,靠,又没有,我查pear结果出来个“啥是B啊(shakespeare)”:
 bruce > ~ > brew search pear
==> Formulae
shakespeare

我想,难道又要用源码包安装?查啊查,度娘问完问谷姐,最后发现是这样装的:

因为我是Mac,所以在https://pear.php.net/manual/en/installation.getting.php 中搜索:Mac

curl -O https://pear.php.net/go-pear.phar
php -d detect_unicode=0 go-pear.phar
 
就是先下载,再用php安装,安装过程我也没记下来,反正应该没什么难度!
最后,终于安装好pear了,这样就可以使用pecl了。
我只不过想安装个amqp扩展而已,结果折腾了半天,现在终于装好了,来吧,开始安装amqp扩展了:pecl install amqp ,擦,报错。。。我已经记不住是什么错误了,反正就是无法安装,我也不知道怎么解决!
最后我尝试重新安装php:brew install php,安装完后,再用pecl install amqp,bingo,成功了!brew services restart php重启一php-fpm就可以在phpinfo里查到有这个扩展了!但我看了一下php.ini,发现果然像网上一个老外说的,It's very stupid that the pecl put the extension reference to the top of the php.ini,就是说pecl安装完php的扩展后,确实是会自动住php.ini添加一行启用扩展的语句,即extension=xxxx.so这种,但是这样太傻B了,竟然直接添加到php.ini顶部去了,因为我们都知道,这个语句应该放到php.ini中的这个区域:
;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;
虽然不影响运行,但是总感觉怪怪的!不过我还是不去移动它,因为所有插件都是这么装的,每个都移动一下太麻烦了,反正这样也能用!
也就是说如果要使用pecl安装扩展,需要重新安装php最新版,直接brew install php就可以了,以前用brew install php71,brew install php@71这样的方式安装过的,也可以用brew install php再次安装,不会覆盖原来版本的,但是好像会提示要覆盖什么东西,我安装的时候没记录下来,大家自己根据提示操作吧。
四、总结

总之,现在Mac安装php扩展的方式不能用brew了,找成用pecl安装了

1、你需要用brew install php重新安装php(放心,不会覆盖以前的版本)
2、你需要安装pear(安装了pear就可以使用pecl install xdebug这样的方式安装php扩展了)
 
如有错误请大家指出!
 
 
 

Mac homebrew-1.5以后安装php扩展的方法的更多相关文章

  1. PHP安装扩展mcrypt以及相关依赖项 【PHP安装PECL扩展的方法】

    一:Mcrypt简介 Mcrypt是PHP的一个扩展,完成了常用加密算法的封装.其实该扩展是对mcrypt标准类库的封装,mcrypt完成了相当多的常用加密算法,如DES, TripleDES, Bl ...

  2. MAC: Homebrew(代替yum)安装

    安装    ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"    最新方式请 ...

  3. Linux centos7下php安装cphalcon扩展的方法

    说明: 操作系统:CentOS7 php安装目录:/usr/local/php php.ini配置文件路径:/usr/local/php/etc/php.ini 运行环境:LNMP ,PHP7 .安装 ...

  4. Linux centos下php安装cphalcon扩展的方法

    说明: 操作系统:CentOS php安装目录:/usr/local/php php.ini配置文件路径:/usr/local/php/etc/php.ini 1.安装cphalcon cd /usr ...

  5. 无需重新编译安装PHP扩展的方法

    转自:https://www.jianshu.com/p/ae3c17b0f126 PHP扩展模块通常有两种: PHP官方扩展.如果php通过源码安装(php7),安装的时候未开启,而后来需要开启某个 ...

  6. mac系统 php 7.2安装memcache扩展

    memcache的安装 下载地址:https://github.com/websupport-sk/pecl-memcache/archive/php7.zip wget https://github ...

  7. php7安装php-redis扩展

    注:操作系统10.13.3 版本,其他版本的Mac系统应该也是可以的 先安装 按照顺序在命令行执行下面命令,如果当前用户权限不够的话,执行命令加上 sudo cd /usr/local/Cellar ...

  8. 【转】如何编译安装PHP扩展

    本文参考 一开始安装PHP的时候,我们并不知道需要哪些扩展,所以只有等到我们真正用到的时候才想办法去安装. 安装PHP扩展最简单的办法就是 sudo apt-get install php5-xxx ...

  9. Linux安装redis PHP安装Redis扩展 and基本命令

    一.安装redis 用超级管理员身份运行: $ mkdir /usr/local/redis #redis安装目录 $ cd /usr/local/src #安装包下载目录 $ wget http:/ ...

随机推荐

  1. DataTable的Merge\COPY\AcceptChange使用说明

    在C#内使用DataTable的Merge().Copy().AcceptChange().Clone()方法的用途如下: 1.Merge()可将两个不同的表结构的表进行合并,合并后新表的列为之前两表 ...

  2. 201771010126 王燕《面向对象程序设计(Java)》第十六周学习总结

    实验十六  线程技术 实验时间 2017-12-8 1.实验目的与要求 (1) 掌握线程概念: ‐多线程 是进程执行过中产生的多条线索. 是进程执行过中产生的多条线索. 是进程执行过中产生的多条线索. ...

  3. 音视频编解码技术(二):AAC 音频编码技术

    一.AAC编码概述 AAC是高级音频编码(Advanced Audio Coding)的缩写,出现于1997年,最初是基于MPEG-2的音频编码技术,目的是取代MP3格式.2000年,MPEG-4标准 ...

  4. [Swift]LeetCode646. 最长数对链 | Maximum Length of Pair Chain

    You are given n pairs of numbers. In every pair, the first number is always smaller than the second ...

  5. [Swift]LeetCode785. 判断二分图 | Is Graph Bipartite?

    Given an undirected graph, return true if and only if it is bipartite. Recall that a graph is bipart ...

  6. [Swift]LeetCode841. 钥匙和房间 | Keys and Rooms

    There are N rooms and you start in room 0.  Each room has a distinct number in 0, 1, 2, ..., N-1, an ...

  7. 微信小程序开发小结

    1.点击按钮分享功能: 使用Button组件,设置open-type="share",然后在js文件的onShareAppMessage方法中设置如下: onShareAppMes ...

  8. Json数组转换字符串、字符串转换原数组......

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  9. ThinkPHP 数据库操作(六) : 查询事件、事务操作、监听SQL

    查询事件 查询事件(V5.0.4+) 从 5.0.4+ 版本开始,增加了数据库的CURD操作事件支持,包括: 查询事件仅支持 find . select . insert . update 和 del ...

  10. HTML常用特殊字符编码对照表以及其对应英文

    符号 说明 对应编码(使用时去掉空格) 英文 & AND 符号 & amp; ampersand < 小于 & lt; little > 大于 & gt; ...