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

MacSiliconM1编译安装PHP8&Swoole4.6ARM64全过程记录

时间:2023-03-29 23:44:05 PHP

最近拿到了一台M1Macmini,准备用它来开发mixphpv3版本。之前试了好几次都没编译成功。今天我再次尝试安装它。网上很多人的文章都有问题(可能是系统环境不一样),特此分享,让后续的人闭坑。面临的问题因为最新版本的macOSBigSur即使关闭安全模式/usr/lib也无法写入文件,所以makeinstall无法安装任何php扩展,所以如果要安装Swoole只能编译安装php到/usr/local目录%csrutilstatusSystemIntegrityProtectionstatus:disabled.%mkdir/usr/lib/php/extensions/testmkdir:/usr/lib/php/extensions/test:Read-onlyfilesystemPHPBuildcanonlyusex64因为brewarm64版本无法使用版本安装了一些依赖,导致后来出现了很多问题。我想编译一个x64PHP+Swoole。编译x64Swoole时,异常没有继续。而是研究了arm64PHP+Swoolearch-x86_64brewinstallopensslzlibcurllibjpeglibpnglibxml2gettextfreetypepcrelibiconvlibzip参数中的路径需要根据自己电脑实际安装路径替换./configure--prefix=/usr/local/php8.0.7--with-config-file-path=/usr/local/php8.0.7/etc--with-config-file-scan-dir=/usr/local/php8.0.7/etc/php.d--enable-fpm--with-fpm-user=www--with-fpm-group=www--with-mysqli=mysqlnd--with-pdo-mysql=mysqlnd--enable-xml--disable-rpath--enable-bcmath--enable-shmop--enable-sysvsem--enable-mbregex--enable-mbstring--enable-ftp--with-mhash--enable-tokenizer--enable-pcntl--enable-sockets--enable-soap--enable-simplexml--without-梨--with-pear--with-zlib=/usr/local/opt/zlib--with-curl=/usr/local/Cellar/curl/7.77.0--with-openssl=/usr/local/Cellar/openssl@1.1/1.1.1k--with-iconv=/usr/local/Cellar/libiconv/1.16makePHPBuildERROR:Nopackage'openssl'found需要编译安装arm64:openssl(系统自带的LibreSSL不能)基于OpenSSLforMacSiliconM1编译:https://segmentfault.com/a/11...sudocp/usr/local/openssl/lib/pkgconfig/*/usr/local/lib/pkgconfig/继续编译:php(with-with-opensslreplacedwith/usr/local/openssl)PHPBuildERROR:configure:error:Pleasereinstalltheiconvlibraryneedstocompileandinstallarm64:iconvwgethttp://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gztarxvzflibiconv-1.14.tar.gzcdlibiconv-1.14./configure--prefix=/usr/local/libiconvmake&&sudomakeinstallCon继续编译:php(将--with-iconv替换为/usr/local/libiconv)PHP构建错误:ld:警告:忽略文件/usr/local/Cellar/oniguruma/6.9.7.1/lib/libonig.dylib,为macOS-arm64构建但尝试链接为macOS-x86_64构建的文件需要编译和安装arm64:onigurumawgethttps://github.com/kkos/oniguruma/archive/v6.9.5_rev1.tar.gztarxvzfv6.9.5_rev1.tar.gzcdoniguruma-6.9.5_rev1./autogen.shOniguruma构建错误:autoreconf:错误:aclocal失败,退出状态:2需要安装:automake,如果安装的是x64,也可以使用arch-x86_64brewinstallautomake继续编译:oniguruma./autogen.sh./configure--prefix=/usr/local/onigurumake&&sudomakeinstall删除x64oniguruma和arm64oniguruma链接到系统arch-x86_64brewuninstallonigurumasudocp/usr/local/oniguruma/lib/pkgconfig/*/usr/local/lib/pkgconfig/sudocp/usr/local/oniguruma/include/*/usr/local/include/exportLDFLAGS="-L/usr/local/oniguruma/lib"exportCPPFLAGS="-I/usr/local/oniguruma/include"exportPKG_CONFIG_PATH="/usr/local/oniguruma/lib/pkgconfig“制作clean./configure--prefix=/usr/local/php8.0.7--with-config-file-path=/usr/local/php8.0.7/etc--with-config-file-scan-dir=/usr/local/php8.0.7/etc/php.d--enable-fpm--with-fpm-user=www--with-fpm-group=www--with-mysqli=mysqlnd--with-pdo-mysql=mysqlnd--enable-xml--disable-rpath--enable-bcmath--enable-shmop--enable-sysvsem--enable-mbregex--enable-mbstring--enable-ftp--with-mhash--enable-tokenizer--enable-pcntl--enable-sockets--enable-soap--enable-simplexml--without-pear--with-pear--with-zlib=/usr/local/opt/zlib--with-curl=/usr/local/Cellar/curl/7.77.0--with-openssl=/usr/local/openssl--with-iconv=/usr/local/libiconvmakePHPBuildERROR:ld:can'twriteoutputfile:sapi/phpdbg/phpdbgforarchitecturearm64sudomake&&sudomakeinstallPHP构建错误:PEAR包PHP_Archive未安装:生成的phar将需要启用PHP的phar扩展。忽略这个异常PHPBuildERROR:AllocationofJITmemoryfailed,PCREJITwillbedisabled。这可能是由安全限制引起的。任何一个授予PHP分配可执行内存的权限,或者设置pcre.jit=0sudovim/Users/liujian/Downloads/php-8.0.7/ext/phar/phar.phpaddini_set("pcre.jit","0");sudomakeinstallSwooleBuild添加--enable-thread-context,并指定--with-openssl-dir为编译版本wget的路径https://github.com/swoole/swoole-src/archive/refs/tags/v4.6.7.ta??r.gztarxvzfv4.6.7.ta??r.gzcdswoole-src-4.6.7./configure--with-php-config=/usr/local/php8.0.7/bin/php-config--启用-openssl--enable-http2--enable-thread-context--with-openssl-dir=/usr/local/opensslmake&&sudomakeinstall

最新推荐
猜你喜欢