TODO:macOS编译PHP7.1

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了TODO:macOS编译PHP7.1相关的知识,希望对你有一定的参考价值。

TODO:macOS编译php7.1

技术分享

本文主要介绍在macOS上编译PHP7.1,有兴趣的朋友可以去尝试一下。

1.下载PHP7.1源码,建议到PHP官网下载纯净到源码包php-7.1.0.tar.gz

2.解压php-7.1.0.tar.gz包

3.创建配置

./configure –prefix=/usr/local/php7 –with-apxs=/usr/sbin/apxs –enable-fpm –with-fpm-user=www –with-fpm-group=www –with-mysqli –with-pdo-mysql –with-iconv-dir –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir=/usr –enable-xml –disable-rpath –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –with-curl –enable-mbregex –enable-mbstring –with-mcrypt –enable-ftp –with-gd –enable-gd-native-ttf –with-openssl –with-mhash –enable-pcntl –enable-sockets –with-xmlrpc –enable-zip –enable-soap –without-pear –with-gettext –disable-fileinfo –enable-maintainer-zts

4.编译代码

make

技术分享

make test

技术分享

5.安装php

make install

技术分享

6.顺利的花这样就把php7.1编译好了,把php7对应的执行文件拷贝到/usr/bin/ 即可在终端使用了

sudo cp /usr/local/php7/bin/ph* /usr/bin/

技术分享

技术分享

7.编译步骤是很简单,但是编译过程难免会遇到一些问题,以下是小编遇到的问题总结

8.安装autoconf

技术分享

9.openssl版本问题

configure: error: OpenSSL version 1.0.1 or greater required.

技术分享

技术分享

安装更高版本的openssl或者下载openssl源码来编译,简单的方法就是使用brew来安装

技术分享

10.Cannot find libz,这个需要安装xcode-select,在终端输入xcode-select –install

技术分享

技术分享

技术分享

11.Cannot locate header file libintl.h

技术分享

安装gettext

技术分享

编辑php源码configure文件

技术分享

改成

技术分享

12.mcrypt.h not found. Please reinstall libmcrypt.

技术分享

安装libmcrypt

技术分享

13. 基本就是遇到这些情况了,还有一种使用php7的方法就是安装MAMP,是商业软件存在试用期限制,可以把安装好的php7文件取出来使用,小编试过,可以正常使用。


wxgzh:ludong86

技术分享


以上是关于TODO:macOS编译PHP7.1的主要内容,如果未能解决你的问题,请参考以下文章

CentOS7编译安装php7.1

centos 6.8 安装编译php7.1.2

debian系统安装最新lnmp编译最新php7.1.2及nginx1.10.3及mysql5.7及5.6

CentOS7 + Nginx1.13.5 + PHP7.1.10 + MySQL5.7.19 源码编译安装

PHP - windows下编译PHP 7.1的memcache

MacOS HighSierra - 如何告诉 Apache 使用 PHP 7.2.9 而不是 PHP 7.1.16