首页 > 后端开发 > PHP7 > 正文

mac 怎么编译安装 php7

藏色散人
发布: 2021-12-16 10:15:01
原创
3893人浏览过
mac编译安装php7的方法:1、通过“wget -c http://mirrors.sohu.com/php/php-7.1.8.tar.gz”下载PHP;2、通过“tar -zxvf php-7.1.8.tar.gz”解压编译即可。

mac 怎么编译安装 php7

本文操作环境:macOS10.15系统,PHP7.1.8版,macbook pro 2020电脑。

mac 怎么编译安装 php7?

Mac编译安装PHP7.1.8:

1、下载稳定版本的PHP

wget -c http://mirrors.sohu.com/php/php-7.1.8.tar.gz
登录后复制

2、解压编译

tar -zxvf php-7.1.8.tar.gz

./configure --prefix=/usr/local/php/7.1.8 \
--with-config-file-path=/usr/local/php/7.1.8/etc \
--with-config-file-scan-dir=/usr/local/php/7.1.8/etc/conf.d \
--with-apxs2=/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-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-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--without-pear \
--with-gettext \
--disable-fileinfo \
--enable-maintainer-zts \
--enable-mysqlnd
登录后复制
遇到的问题:
  • apxs报错的问题
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)
登录后复制

解决方案:查找httpd安装目录下的bin目录里的 apxs ,尽量不要写/usr/bin/apxs

立即学习PHP免费学习笔记(深入)”;

  • 由于Mac自带的openssl没法升级(我没找到升级的办法),导致版本较低,报错:
configure: error: OpenSSL version 1.0.1 or greater required.
登录后复制

解决方案:由于Mac自带的openssl没法升级(我没找到升级的办法),用

brew install openssl
登录后复制

安装最新版的openssl,然后在参数中加上brew安装的ssl的路径

--with-openssl=/usr/local/Cellar/openssl@1.1/1.1.0e
登录后复制
  • --with-gettext报错
configure: error: Cannot locate header file libintl.h
登录后复制

解决方案:

brew install gettext
登录后复制

打开PHP的 configure文件,修改文件的

for i in $PHP_GETTEXT /usr/local /usr/ ;do
登录后复制

改成

for i in $PHP_GETTEXT /usr/local /usr/ usr/local/opt/gettext;do
登录后复制
  • libiconv问题,报错如下:
checking for iconv... no
checking for libiconv... no
configure: error: Please specify the install prefix of iconv with --with-iconv=<DIR>
登录后复制

解决方案:
安装 libiconv (字符编码转换库)
网站地址: http://www.gnu.org/software/libiconv/
当前版本: https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz

$ wget [https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz
$ tar zxvf libiconv-1.15.tar.gz
$ cd libiconv-1.15
$ ./configure --prefix=/usr/local/lib/libiconv
$ make
$ sudo make install
登录后复制

安装

make && sudo make install
登录后复制

推荐学习:《PHP7教程

以上就是mac 怎么编译安装 php7的详细内容,更多请关注php中文网其它相关文章!

PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
相关标签:
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

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