设置brewbrew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/homebrew-php
安装php7brew install php70 \
--without-snmp \
--without-apache \
--with-debug \
--with-fpm \
--with-intl \
--with-homebrew-curl \
--with-homebrew-libxslt \
--with-homebrew-openssl \
--with-imap \
--with-mysql \
--with-tidy
configure的时候,报错了:checking for ZLIB support... yes
checking if the location of ZLIB install directory is defined... no
configure: error: Cannot find libz
安装 xcode-selectxcode-select--install
安装好了之后。继续php7
配置文件目录
php.ini/usr/local/etc/php/7.0/php.ini
php-fpm.conf/usr/local/etc/php/7.0/php-fpm.conf
php, phpize, php-conigls /usr/local/opt/php70/bin
phar php php-cgi php-config phpize
php-fpm/usr/local/opt/php70/sbin/php-fpm
测试
php版本➜/usr/local/opt/php70/bin/php-v
PHP7.0.4(cli)(built:Mar15201615:40:41)(NTS)
Copyright(c)1997-2016ThePHPGroup
ZendEnginev3.0.0,Copyright(c)1998-2016ZendTechnologies
withZendOPcachev7.0.6-dev,Copyright(c)1999-2016,byZendTechnologies
withXdebugv2.4.0,Copyright(c)2002-2016,byDerickRethans
php-fpm版本PHP7.0.4(fpm-fcgi)(built:Mar15201615:40:46)
Copyright(c)1997-2016ThePHPGroup
ZendEnginev3.0.0,Copyright(c)1998-2016ZendTechnologies
withZendOPcachev7.0.6-dev,Copyright(c)1999-2016,byZendTechnologies
withXdebugv2.4.0,Copyright(c)2002-2016,byDerickRethans
启动php-fpm
//删掉老的sudo pkill php-fpm
//启动新的sbin git:(master)/usr/local/opt/php70/sbin/php-fpm
[15-Mar-201616:58:06]NOTICE:[pool www]'user'directiveisignoredwhenFPMisnotrunningasroot
[15-Mar-201616:58:06]NOTICE:[pool www]'group'directiveisignoredwhenFPMisnotrunningasroot
[15-Mar-201616:58:06]NOTICE:fpmisrunning,pid43008
[15-Mar-201616:58:06]NOTICE:ready to handle connections
打开 index.php 里的phpinfo()看是否是php7.0.4版本了。
安装扩展
redisbrew install php70-redis
配置文件:/usr/local/etc/php/7.0/conf.d/ext-redis.ini
memcachedbrew install php70-memcached
配置文件:/usr/local/etc/php/7.0/conf.d/ext-memcached.ini
swoolebrew install php70-swoole
配置文件:/usr/local/etc/php/7.0/conf.d/ext-swoole.ini
其他扩展类似这样安装。