[关闭]
@phper 2016-03-15T09:14:46.000000Z 字数 1888 阅读 18151

mac上通过brew安装php7

php


在mac上安装软件很爽,用brew就搞定了。现在纪录下,用brew安装php7。

设置brew

  1. brew tap homebrew/dupes
  2. brew tap homebrew/versions
  3. brew tap homebrew/homebrew-php

安装php7

  1. brew install php70

报错了?

configure的时候,报错了:

checking for ZLIB support... yes
checking if the location of ZLIB install directory is     defined... no
configure: error: Cannot find libz

但是,我查看 libz 其实是有安装的。

brew search zlib
homebrew/dupes/zlib ✔   lzlib

通过google 和查看 Cannot find libz 发现需要安装 xcode-select

安装 xcode-select

  1. xcode-select --install

会弹框出来。点击安装就可以了:

安装好了之后。继续

brew install php70

一段时间之后,安装成功了。

配置文件目录

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-conig

ls /usr/local/opt/php70/bin
phar    php  php-cgi  php-config   phpize

php-fpm

/usr/local/opt/php70/sbin/php-fpm

测试

php版本

  1. /usr/local/opt/php70/bin/php -v
  2. PHP 7.0.4 (cli) (built: Mar 15 2016 15:40:41) ( NTS )
  3. Copyright (c) 1997-2016 The PHP Group
  4. Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
  5. with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
  6. with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans

php-fpm版本

  1. PHP 7.0.4 (fpm-fcgi) (built: Mar 15 2016 15:40:46)
  2. Copyright (c) 1997-2016 The PHP Group
  3. Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
  4. with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
  5. with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans

启动php-fpm

  1. //删掉老的
  2. sudo pkill php-fpm
  3. //启动新的
  4. sbin git:(master) /usr/local/opt/php70/sbin/php-fpm
  5. [15-Mar-2016 16:58:06] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
  6. [15-Mar-2016 16:58:06] NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root
  7. [15-Mar-2016 16:58:06] NOTICE: fpm is running, pid 43008
  8. [15-Mar-2016 16:58:06] NOTICE: ready to handle connections

打开 index.php 里的 phpinfo()看是否是php7.0.4版本了。

安装扩展

redis

  1. brew install php70-redis

配置文件:

  1. /usr/local/etc/php/7.0/conf.d/ext-redis.ini

memcached

  1. brew install php70-memcached

配置文件:

  1. /usr/local/etc/php/7.0/conf.d/ext-memcached.ini

swoole

  1. brew install php70-swoole

配置文件:

  1. /usr/local/etc/php/7.0/conf.d/ext-swoole.ini

其他扩展类似这样安装。

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注