当前位置: 首页 > 后端技术 > PHP

【安装】在mac上安装PHP7的心得

时间:2023-03-29 14:06:41 PHP

背景前几天在mac上跑了workrman。由于workerman需要开启多进程,多进程需要pcntl扩展的支持。我之前用brew安装的php71没有这个扩展,直接卸载了。拿到了php71,然后想下载源码编译安装更高版本的php7,也可以更自由的安装扩展。源码编译安装(php-7.2.7)问题一configure:警告:你应该使用--build,--host,--targetconfigure:警告:无效主机类型:configure:警告:你应该使用--build,--主机,--targetconfigure:警告:主机类型无效:--enable-fpmconfigure:警告:你应该使用--build,--host,--targetconfigure:警告:主机类型无效:--with-mysqlicconfigure:警告:你应该使用--build、--host、--targetconfigure:警告:主机类型无效:--with-pdo-mysqlconfigure:警告:你应该使用--build、--host、--targetconfigure:警告:主机类型无效:--with-iconv-dirconfigure:警告:你应该使用--build,--host,--targetconfigure:警告:无效的主机类型:--with-eeeetype-dirconfigure:警告:你应该使用--build,--host,--targetconfigure:警告:主机类型无效:--with-zlibconfigure:警告:你应该使用--build,--host,--targetconfigure:警告:主机类型无效:--with-jpeg-dirconfigure:警告:你应该使用--build,--host,--targetconfigure:WARNING:invalidhosttype:--with-png-dirconfigure:error:invalidvariablename:`--with-libxml-dir'解决方法:都是因为前面多了一个of--with空间问题2抱歉,我无法运行apxs。可能的原因如下:1.没有安装Perl2.没有找到apxs。尝试使用--with-apxs2=/path/to/apxs3传递路径。Apachewasnotbuiltusing--enable-so(显示apxs使用页面)解决方案brewinstallhttpdfind/-nameapxsCentos下执行yuminstall-yhttpd-devel找到apxs文件路径,然后修改编译参数为遵循--with-apxs2=/usr/local/bin/apxs问题3检查是否定义了ZLIB安装目录的位置...否;配置:错误:找不到libz。解决办法是brewinstallzlibfind/-namelib加参数--with-zlib-dir=/usr/local/Cellar/zlib/1.2.11参考链接问题4configure:error:Cannotlocateheaderfilelibintl.h原因是没有gettext解决方案:$PHP_GETTEXT/usr/local/usr;将doconfigure文件更改为foriin$PHP_GETTEXT/usr/local/usr/usr/local/opt/gettext;请参考链接问题5configure:error:Pleasespecifytheinstallprefixoficonvwith--with-iconv=

解决办法,在-liconv中的iconv的编译参数中加入\--with-iconv=/usr/local/Cellar/libiconv/1.15...noconfigure:error:Pleasereinstalltheiconv库。【最后卡在这里,没有解决然后编译安装没有成功】最后解决问题五时的编译安装命令如下:./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\--onssl\--with-mhash\--enable-pcntl\--enable-sockets\--with-xmlrpc\--enable-zip\--enable-soap\--without-pear\--with-gettext\--disable-fileinfo\--enable-maintner-zts\--enable-mysqlndbrew安装1.在brew中搜索phpbrew搜索php出现:php@5.6php@7.1php@7.02。然后装php7.0brewinstallphp703。给系统环境变量设置phpfind/-namephp#首先找到php执行文件cp/usr/local/Cellar/php@7.0/7.0.30_1/bin/php/usr/bin#把php执行文件放在/usr/bin/文件夹,最后编译安装源码没有成功,还是brewinstall安装成功