MAC下⾯源码编译安装PHP7.1
在mac下⾯编译php还是遇到不少坑的,下⾯就我在安装过程中遇到的问题及解决⽅案记录下来供各位仁者参考。系统环境
macOs版本:10.13.6
PHP版本:php7.1.21
安装依赖
brew install libjpeg libpng libxml gettext openssl freetype pcre
这⾥就不再说明brew的安装⽅法了,请⾃⾏百度
$ cd libiconv-1.15
$ ./configure
$ make
$ sudo make install
PHP编译安装
./configure --prefix=/usr/local/php/7.1 \
--with-config-file-path=/usr/local/php/7.1/etc \
--with-config-file-scan-dir=/usr/local/php/7.1/etc/conf.d \
--enable-fpm \
--with-fpm-user=yluchao \
--with-fpm-group=admin \
--with-mysqli \
--with-pdo-mysql \
--with-iconv-dir=/usr/local \
--enable-short-tags \
-
-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 \php8兼容php7吗
--enable-mbstring \
--with-mcrypt \
--enable-ftp \
--with-gd \
--enable-gd-native-ttf \
--with-openssl=/usr/local/opt/openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
-
-with-xmlrpc \
--enable-zip \
--enable-soap \
--without-pear \
--disable-fileinfo \
--enable-maintainer-zts \
--enable-mysqlnd
注:
新版本会同时检测 gettext喝iconv。所以安装时先去除gettext等php安装成功后,再去增加gettext扩展
如果make时报此错误
z -licucore -lm -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm -o sapi/cli/php
Undefined symbols for architecture x86_64:
"_libiconv", referenced from:
_do_convert in gdkanji.o
_zif_iconv_substr in iconv.o
_zif_iconv_mime_encode in iconv.o
_php_iconv_string in iconv.o
__php_iconv_strlen in iconv.o
__php_iconv_strpos in iconv.o
__php_iconv_appendl in iconv.o
...
"_libiconv_close", referenced from:
_do_convert in gdkanji.o
_zif_iconv_substr in iconv.o
_zif_iconv_mime_encode in iconv.o
_php_iconv_string in iconv.o
__php_iconv_strlen in iconv.o
__php_iconv_strpos in iconv.o
__php_iconv_mime_decode in iconv.o
...
"_libiconv_open", referenced from:
_do_convert in gdkanji.o
_zif_iconv_substr in iconv.o
_zif_iconv_mime_encode in iconv.o
_php_iconv_string in iconv.o
__php_iconv_strlen in iconv.o
__php_iconv_strpos in iconv.o
__php_iconv_mime_decode in iconv.o
...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [sapi/cli/php] Error 1
解决⽅案:
vim Makefile⽂件
到 这两个关键词EXTRA_LDFLAGS和EXTRA_LDFLAGS_PROGRAM删除
EXTRA_LDFLAGS = -L/Library/Developer/CommandLineTools/SDKs/MacOSX10.13.sdk/usr/lib -L/usr/local/opt/openssl/lib -L/usr/local/lib -L/usr/local EXTRA_LDFLAGS_PROGRAM = -L/Library/Developer/CommandLineTools/SDKs/MacOSX10.13.sdk/usr/lib -L/usr/local/opt/openssl/lib -L/usr/local/lib
删除-L/Library/Developer/CommandLineTools/SDKs/MacOSX10.13.sdk/usr/lib 类似此字符串的字符
安装gettext扩展
⾸先在{源码⽬录}/ext/gettext 执⾏/usr/local/php/7.1/bin/phpize(根据⾃⼰环境可变)。成功后安装扩展。
./configure --with-php-config=/usr/local/php/7.1/bin/php-config --with-gettext=/usr/local/opt/gettext
make & sudo make install
添加扩展配置
sudo vim /usr/local/php/7.1/etc/conf.d/gettext.ini
增加:extension=/usr/local/php/7.1/lib/php/extensions/no-debug-zts-20160303/gettext.so
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论