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”解压编译即可。
本文操作环境macos10.15系统,php7.1.8版,macbook pro 2020电脑。
mac 怎么编译安装 php7?
mac编译安装php7.1.8:
1. 下载稳定版本的phpwget -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 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)解决方案查找httpd安装目录下的bin目录里的 apxs ,尽量不要写/usr/bin/apxs
由于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;dolibiconv问题,报错如下checking for iconv... nochecking for libiconv... noconfigure: 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教程》