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

广告:宝塔服务器面板,一键全能部署及管理,送你10850元礼包,点我领取~~~

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

背景

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

源码编译安装(php-7.2.7)

问题一

configure: WARNING: you should use --build, --host, --targetconfigure: WARNING: invalid host type:configure: WARNING: you should use --build, --host, --targetconfigure: WARNING: invalid host type:  --enable-fpmconfigure: WARNING: you should use --build, --host, --targetconfigure: WARNING: invalid host type:  --with-mysqliconfigure: WARNING: you should use --build, --host, --targetconfigure: WARNING: invalid host type:  --with-pdo-mysqlconfigure: WARNING: you should use --build, --host, --targetconfigure: WARNING: invalid host type:  --with-iconv-dirconfigure: WARNING: you should use --build, --host, --targetconfigure: WARNING: invalid host type:  --with-eeeetype-dirconfigure: WARNING: you should use --build, --host, --targetconfigure: WARNING: invalid host type:  --with-zlibconfigure: WARNING: you should use --build, --host, --targetconfigure: WARNING: invalid host type:  --with-jpeg-dirconfigure: WARNING: you should use --build, --host, --targetconfigure: WARNING: invalid host type:  --with-png-dirconfigure: error: invalid variable name: ` --with-libxml-dir'
登录后复制

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

问题二

Sorry, I cannot run apxs. Possible reasons follow:1. Perl is not installed2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs3. Apache was not built using --enable-so (the apxs usage page is displayed)
登录后复制

解决办法

brew install httpdfind / -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 zlibfind / -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
登录后复制

问题五

Sorry, I cannot run apxs. Possible reasons follow:1. Perl is not installed2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs3. Apache was not built using --enable-so (the apxs usage page is displayed)0
登录后复制

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

Sorry, I cannot run apxs. Possible reasons follow:1. Perl is not installed2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs3. Apache was not built using --enable-so (the apxs usage page is displayed)1
登录后复制

问题六

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

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

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

./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  Sorry, I cannot run apxs. Possible reasons follow:1. Perl is not installed2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs3. Apache was not built using --enable-so (the apxs usage page is displayed)1 \--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

Sorry, I cannot run apxs. Possible reasons follow:1. Perl is not installed2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs3. Apache was not built using --enable-so (the apxs usage page is displayed)4
登录后复制

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

2.然后安装了php7.0

Sorry, I cannot run apxs. Possible reasons follow:1. Perl is not installed2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs3. Apache was not built using --enable-so (the apxs usage page is displayed)5
登录后复制

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

Sorry, I cannot run apxs. Possible reasons follow:1. Perl is not installed2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs3. Apache was not built using --enable-so (the apxs usage page is displayed)6
登录后复制

最后

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

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

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

9543建站博客
一个专注于网站开发、微信开发的技术类纯净博客。
作者头像
admin创始人

肥猫,知名SEO博客站长,14年SEO经验。

上一篇:vue的三种安装方法
下一篇:聊聊laravel token报错的原因和解决方法

发表评论

关闭广告
关闭广告