//安装PHP7
命令:$ brew install php70
//删掉以前安装的PHP5.6
//你可以根据自己的情况来修改
命令:$ brew unlink php56
命令:$ brew link php70
//大功告成$ php -v PHP 7.0.0
(cli) (built:Dec2 2015 13:06:23) ( NTS )Copyright(c) 1997-2015 The PHPGroupZend Engine v3.0.0,Copyright(c) 1998-2015 Zend Technologies
➜~/usr/local/opt/php56/sbin/php-fpm
[26-Mar-2016 12:15:40] NOTICE: PHP message: PHP Warning:PHP Startup: mcrypt: Unable to initialize module
Module compiled with build ID=API20131226,NTS
PHPcompiled with build ID=API20131226,NTS,debug
These options need to match
in Unknown on line 0
Warning:PHP Startup: mcrypt: Unable to initialize module
Module compiled with build ID=API20131226,NTS
PHPcompiled with build ID=API20131226,NTS,debug
These options need to match
inUnknownon line0
Unknown(0) : Warning - PHP Startup: mcrypt: Unable to initialize module
Module compiled with build ID=API20131226,NTS
PHPcompiled with build ID=API20131226,NTS,debug
These options need to match
[26-Mar-2016 12:15:40] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
[26-Mar-2016 12:15:40] NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root
[26-Mar-2016 12:15:40] ERROR: unable to bind listening socket for address '127.0.0.1:9000': Address already in use (48)
[26-Mar-2016 12:15:40] ERROR: FPM initialization failed
解决办法,在终端执行如下命令
brew reinstall php56-mcrypt --build-from-source
参考PHP Warning: PHP Startup: ????????: Unable to initialize module
上一步完成后,又出现如下问题
➜~sudo /usr/local/opt/php56/sbin/php-fpm
Password:
[26-Mar-2016 12:40:10] ERROR: unable to bind listening socket for address '127.0.0.1:9000': Address already in use (48)
[26-Mar-2016 12:40:10] ERROR: FPM initialization failed
查看谁占用了9000端口
➜~sudo lsof -i:9000
COMMAND PID USERFDTYPEDEVICE SIZE/OFF NODE NAME
php-fpm 707 root7uIPv4 0x9177969b065b477d0t0TCP localhost:cslistener (LISTEN)
php-fpm 708 _www0uIPv4 0x9177969b065b477d0t0TCP localhost:cslistener (LISTEN)
php-fpm 709 _www0uIPv4 0x9177969b065b477d0t0TCP localhost:cslistener (LISTEN)
php-fpm 710 _www0uIPv4 0x9177969b065b477d0t0TCP localhost:cslistener (LISTEN)
杀掉进程id 707、708、709、710
➜~sudo kill -9 707
➜~sudo kill -9 708
➜~sudo kill -9 709
➜~sudo kill -9 710
➜~sudo /usr/local/opt/php56/sbin/php-fpm
[26-Mar-2016 12:55:29] NOTICE: fpm is running, pid 32706
[26-Mar-2016 12:55:29] NOTICE: ready to handle connections
确认php-fpm监听9000端口
➜~sudo lsof -Pni4 | grep LISTEN | grep php
Password:
php-fpm32898root8uIPv4 0x9177969b057870850t0TCP 127.0.0.1:9000 (LISTEN)
php-fpm32899_www0uIPv4 0x9177969b057870850t0TCP 127.0.0.1:9000 (LISTEN)
php-fpm32900_www0uIPv4 0x9177969b057870850t0TCP 127.0.0.1:9000 (LISTEN)
php-fpm32901_www0uIPv4 0x9177969b057870850t0TCP 127.0.0.1:9000 (LISTEN)
➜~
➜~php-fpm -D
[25-Mar-2016 20:23:28] ERROR: failed to open configuration file '/private/etc/php-fpm.conf': No such file or directory (2)
[25-Mar-2016 20:23:28] ERROR: failed to load configuration file '/private/etc/php-fpm.conf'
[25-Mar-2016 20:23:28] ERROR: FPM initialization failed
➜~
解决方法:
php-fpm --fpm-config /usr/local/etc/php/5.6/php-fpm.conf
又出现了如下错误
➜~php-fpm --fpm-config /usr/local/etc/php/5.6/php-fpm.conf
[25-Mar-2016 20:24:52] ERROR: failed to open error_log (/usr/var/log/php-fpm.log): No such file or directory (2)
[25-Mar-2016 20:24:52] ERROR: failed to post process the configuration
[25-Mar-2016 20:24:52] ERROR: FPM initialization failed
➜~
vim /usr/local/etc/php/5.6/php-fpm.conf
然后添加,error_log = /usr/local/var/log/php-fpm.log 保存
➜~php-fpm --fpm-config /usr/local/etc/php/5.6/php-fpm.conf
[25-Mar-2016 20:29:54] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
[25-Mar-2016 20:29:54] NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root
[25-Mar-2016 20:29:54] NOTICE: fpm is running, pid 1026
[25-Mar-2016 20:29:54] NOTICE: ready to handle connections