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 php@7.1: 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/php@7.1/lib/httpd/modules/libphp7.so

<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>

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/php@7.1/bin:PATH"' >> ~/.bash_profile echo 'export PATH="/usr/local/opt/php@7.1/sbin:PATH"' >> ~/.bash_profile

For compilers to find this software you may need to set:
LDFLAGS: -L/usr/local/opt/php@7.1/lib
CPPFLAGS: -I/usr/local/opt/php@7.1/include

To have launchd start php@7.1 now and restart at login:
brew services start php@7.1
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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容