PHP7PHP实战

mac上通过brew安装php7

2016-12-02  本文已影响4121人  Yii2小虾

第一步:设置brew

brew tap homebrew/dupes

brew tap homebrew/versions

brew tap homebrew/homebrew-php

第二部:安装php7

brew install php70  (建议使用下面的方式)

brew install php70 --with-apxs2  --with-apache --with-gmp --with-imap --with-tidy --with-debug

报错了?

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

(如果报错了需要安装xcode-select,我的没报错!)

安装 xcode-select

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版本

➜/usr/local/opt/php70/bin/php-v

PHP7.0.4(cli)(built:Mar15201615:40:41)(NTS)

Copyright(c)1997-2016ThePHPGroup

php-fpm版本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版本了。

安装扩展

redis

brew install php70-redis

配置文件:

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

memcached

brew install php70-memcached

配置文件:

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

swoole

brew install php70-swoole

配置文件:

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

其他扩展类似这样安装。

感谢:

文章原出处:https://zybuluo.com/phper/note/313803

上一篇下一篇

猜你喜欢

热点阅读