资讯专栏INFORMATION COLUMN

[安装] mac安装PHP7经历

xiongzenghui / 2338人阅读

摘要:背景前几天在上跑,由于需要开启多个进程,多进程需要扩展的支持,我之前那个安装的没有这个扩展,就直接卸载了,然后想下载源码编译安装的更高版本,也可以更自由的安装扩展。

背景

前几天在mac上跑workrman,由于workerman需要开启多个进程,多进程需要pcntl扩展的支持,我之前那个brew安装的php71没有这个扩展,就直接卸载了php71,然后想下载源码编译安装php7的更高版本,也可以更自由的安装扩展。

源码编译安装(php-7.2.7)

问题一

configure: WARNING: you should use --build, --host, --target
configure: WARNING: invalid host type:
configure: WARNING: you should use --build, --host, --target
configure: WARNING: invalid host type:  --enable-fpm
configure: WARNING: you should use --build, --host, --target
configure: WARNING: invalid host type:  --with-mysqli
configure: WARNING: you should use --build, --host, --target
configure: WARNING: invalid host type:  --with-pdo-mysql
configure: WARNING: you should use --build, --host, --target
configure: WARNING: invalid host type:  --with-iconv-dir
configure: WARNING: you should use --build, --host, --target
configure: WARNING: invalid host type:  --with-eeeetype-dir
configure: WARNING: you should use --build, --host, --target
configure: WARNING: invalid host type:  --with-zlib
configure: WARNING: you should use --build, --host, --target
configure: WARNING: invalid host type:  --with-jpeg-dir
configure: WARNING: you should use --build, --host, --target
configure: WARNING: invalid host type:  --with-png-dir
configure: error: invalid variable name: ` --with-libxml-dir"

解决:都是因为—with前面多了个空格


问题二

Sorry, I cannot run apxs. Possible reasons follow:
1. Perl is not installed
2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs
3. Apache was not built using --enable-so (the apxs usage page is displayed)

解决办法

brew install httpd
find / -name apxs 
Centos下执行 yum install -y httpd-devel

查找到apxs文件路径,然后修改编译参数如下

--with-apxs2=/usr/local/bin/apxs   

问题三

checking if the location of ZLIB install directory is defined... no ;
configure: error: Cannot find libz.

解决办法

brew install zlib
find / -name lib

加上参数

--with-zlib-dir=/usr/local/Cellar/zlib/1.2.11

参考链接


问题四

configure: error: Cannot locate header file libintl.h
原因是没有gettext

解决办法:

$PHP_GETTEXT /usr/local /usr; do

configure文件改为

for i in $PHP_GETTEXT /usr/local /usr /usr/local/opt/gettext; do

参考链接


问题五

configure: error: Please specify the install prefix of iconv with --with-iconv=

解决办法,编译参数中加上

--with-iconv=/usr/local/Cellar/libiconv/1.15

参考链接


问题六

checking for libiconv in -liconv... no
checking for iconv in -liconv... no
configure: error: Please reinstall the iconv library.

最终卡在了这里,没解决。然后编译安装就没有成功

最后解决到问题五的时候的编译安装命令如下:

./configure --prefix=/usr/local/php/7.2.7—with-config-file-path=/usr/local/php/7.2.7/etc --with-config-file-scan-dir=/usr/local/php/7.2.7/etc/conf.d  --with-apxs2=/usr/local/bin/apxs --with-zlib-dir=/usr/local/Cellar/zlib/1.2.11 --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysqli --with-pdo-mysql  --with-iconv=/usr/local/Cellar/libiconv/1.15 --with-eeeetype-dir --with-zlib --with-jpeg-dir --with-png-dir --with-libxml-dir=/usr/bin/xml2-config --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-onsnssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --disable-fileinfo --enable-maintnener-zts --enable-mysqlnd
brew安装

1.搜索brew中的php

brew search php

出现了:php@5.6 php@7.1 php@7.0

2.然后安装了php7.0

brew install php70

3.将php设置系统环境变量

find / -name php # 先找到php执行文件
cp /usr/local/Cellar/php@7.0/7.0.30_1/bin/php /usr/bin  # 将php执行文件放到/usr/bin/文件夹中
最后

通过源码编译安装没有成功,还是brew install安装成功

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/29067.html

相关文章

  • PHP性能测试利器-Xdebug和phpstorm

    摘要:是一个开放源代码的程序调试器即一个工具,可以用来跟踪,调试和分析程序的运行状况。以下为安装示例,安装请参考集成开发和断点调试环境的配置。指令的配置路径必须是绝对路径。 Xdebug是一个开放源代码的PHP程序调试器(即一个Debug工具),可以用来跟踪,调试和分析PHP程序的运行状况。以下为Windows+Phpstorm+Xampp+Xdebug安装示例,MAC安装请参考集成开发和断...

    MoAir 评论0 收藏0
  • MAC下尝试PHP7 alpha版本的安装

    摘要:经过鸟哥等众位大神打磨了年的,终于出了发布了版本,安装,真是非常地向下兼容,下载,解压,把之前的配置命令用上,一路回车下去,毫无违和感。首先当然是下载版本的源码包了,去的官网下载即可,为了方便起见,附上下载链接。 经过鸟哥等众位大神打磨了2年的PHP 7,终于出了发布了alpha版本,安装,真是非常地向下兼容,下载,解压,把之前的配置命令用上,一路回车下去,毫无违和感。 首先当然是...

    DC_er 评论0 收藏0
  • PHP开发环境01 - Mac下使用Docker配置PHP环境(只限于学习)

    视频地址 学徒卡夫 - 卡夫的Mac 03 - Mac下使用Docker配置PHP环境 https://www.bilibili.com/vide... 安装 Docker https://www.docker.com/docker... 下载镜像 # 安装基础镜像 - ubuntu:14.04 # 拉取镜像(拉取镜像经常会失败,尝试几次就好了) docker pull ubuntu:14.0...

    gitmilk 评论0 收藏0
  • PHP开发环境01 - Mac下使用Docker配置PHP环境(只限于学习)

    视频地址 学徒卡夫 - 卡夫的Mac 03 - Mac下使用Docker配置PHP环境 https://www.bilibili.com/vide... 安装 Docker https://www.docker.com/docker... 下载镜像 # 安装基础镜像 - ubuntu:14.04 # 拉取镜像(拉取镜像经常会失败,尝试几次就好了) docker pull ubuntu:14.0...

    baukh789 评论0 收藏0
  • Mac OSX 10.12.6编译安装Tengine+PHP7.1

    摘要:先发一下电脑配置,电脑版本如下图安装步骤如下请确保电脑已经关闭。关闭的方法去问下载并且解压。安装前前依赖安装编译安装参数如下安装步骤如下和一样先下载下载依赖包编译安装参数修改将修改为之后的不用修改修改后的如 先发一下电脑配置,电脑版本如下图:showImg(https://segmentfault.com/img/bVYEUW?w=586&h=354); PHP安装步骤如下: 请确...

    codeGoogle 评论0 收藏0

发表评论

0条评论

xiongzenghui

|高级讲师

TA的文章

阅读更多
最新活动
阅读需要支付1元查看
<