登录  /  注册
首页 > 后端开发 > PHP7 > 正文

mac安装PHP7时出现的问题汇总

藏色散人
发布: 2019-09-29 14:13:25
转载
4189人浏览过

mac安装PHP7时出现的问题汇总

背景

前几天在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=<DIR>
登录后复制

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

\--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安装成功。

更多PHP7相关知识,请访问PHP7专题栏目!

以上就是mac安装PHP7时出现的问题汇总的详细内容,更多请关注php中文网其它相关文章!

智能AI问答
PHP中文网智能助手能迅速回答你的编程问题,提供实时的代码和解决方案,帮助你解决各种难题。不仅如此,它还能提供编程资源和学习指导,帮助你快速提升编程技能。无论你是初学者还是专业人士,AI智能助手都能成为你的可靠助手,助力你在编程领域取得更大的成就。
相关标签:
来源:segmentfault网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
作者最新文章
最新问题
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2024 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号