macos 编译php,TODO:macOS编译PHP7.1

本文介绍了如何在macOS上编译PHP7.1。首先从PHP官网下载7.1.0版本源码,然后进行解压。接着配置编译选项,包括安装路径、FPM、MySQL支持等,并执行`configure`。通过`make`和`make install`完成编译和安装。最后将php7.1的执行文件复制到/usr/bin/目录下。在编译过程中可能遇到如openssl版本、libz等问题,解决这些问题后,即可成功安装。
摘要由CSDN通过智能技术生成

TODO:macOS编译PHP7.1

0818b9ca8b590ca3270a3433284dd417.png

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

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

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

3.创建配置

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

4.编译代码

make

0818b9ca8b590ca3270a3433284dd417.png

make test

0818b9ca8b590ca3270a3433284dd417.png

5.安装php

make install

0818b9ca8b590ca3270a3433284dd417.png

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

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

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

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

8.安装autoconf

0818b9ca8b590ca3270a3433284dd417.png

9.openssl版本问题

configure: error: OpenSSL version 1.0.1 or greater required.

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

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

0818b9ca8b590ca3270a3433284dd417.png

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

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

11.Cannot locate header file libintl.h

0818b9ca8b590ca3270a3433284dd417.png

安装gettext

0818b9ca8b590ca3270a3433284dd417.png

编辑php源码configure文件

0818b9ca8b590ca3270a3433284dd417.png

改成

0818b9ca8b590ca3270a3433284dd417.png

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

0818b9ca8b590ca3270a3433284dd417.png

安装libmcrypt

0818b9ca8b590ca3270a3433284dd417.png

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

wxgzh:ludong86

0818b9ca8b590ca3270a3433284dd417.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值