Mac 下 brew install php71

折腾了好几天还是没把 php 的 openssl 扩展给装上,感觉 openssl 和 brew install openssl 的不一致,安装总是失败。是在受不了,把 Mac 升级到 Sierra 10.13, Xcode 显示完全删除,再重新安装 Xcode 7.3。开始提示安装 Xcode 时间需要大概 10 个小时,时间也是在波动,后来发现暂停后再下载,速度提升很多,终于一个多小时就把 Xcode 给装上了,因为 brew 安装 php 对 Xcode 有依赖。

==> Installing dependencies for [email protected]: aspell, freetds, libpng, freetype, libffi,
 pcre, glib, gmp, icu4c, jpeg, libpq, libtool, libzip, mhash, mcrypt, unixodbc, webp
chmod: Unable to change file mode on ./php: Operation not permitted

System Integrity Protection (SIP), is a new feature in El Capitan that protects system processes and folders so even a root user cannot get access to them.

  • Reboot your Mac into Recovery Mode by restarting your computer and holding down Command+R until the Apple logo appears on your screen.

  • Click Utilities > Terminal.

  • csrutil disable

brew 安装 php7(libphp7.so丢失)

brew install php71 --with-apxs2 --with-apache --with-gmp --with-imap --with-tidy --with-debug --with-openssl

To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php7_module /usr/local/opt/[email protected]/lib/httpd/modules/libphp7.so


    SetHandler application/x-httpd-php

Finally, check DirectoryIndex includes index.php
DirectoryIndex index.php index.html

The php.ini and php-fpm.ini file can be found in:
/usr/local/etc/php/7.1/

This formula is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

If you need to have this software first in your PATH run:
echo 'export PATH="/usr/local/opt/[email protected]/bin:PATH"' >> ~/.bash_profile echo 'export PATH="/usr/local/opt/[email protected]/sbin:PATH"' >> ~/.bash_profile

For compilers to find this software you may need to set:
LDFLAGS: -L/usr/local/opt/[email protected]/lib
CPPFLAGS: -I/usr/local/opt/[email protected]/include

To have launchd start [email protected] now and restart at login:
brew services start [email protected]
Or, if you don't want/need a background service you can just run:
php-fpm

502 Bad Gateway

修改php-fpm的配置文件 vim /usr/local/php/etc/php-fpm.conf 里面的 listen = /tmp/php-fcgi.sock 改为 listen = 127.0.0.1:9000

修改nginx的配置文件 vim /usr/local/nginx/conf/nginx.conf 里面的 fastcgi_pass unix:/tmp/php-fcgi.sock; 改为 fastcgi_pass 127.0.0.1:9000;

重启 php-fpm
master进程可以理解以下信号

INT, TERM 立刻终止
QUIT 平滑终止
USR1 重新打开日志文件
USR2 平滑重载所有worker进程并重新载入配置和二进制模块

ps -ef | grep php-fpm
找到 master 主进程
kill -USR2 端口号

启动 php-fpm
/usr/sbin/php-fpm

你可能感兴趣的:(Mac 下 brew install php71)