mac 源码编译安装php8.3.9
创始人
2024-11-11 05:09:18
0

前提条件

确保你已经安装了 HomebrewXcode Command Line Tools。你可以通过以下命令安装它们:

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"  xcode-select --install

https://www.cnblogs.com/niuben/p/16109703.html

安装必要的依赖项

使用 Homebrew 安装 PHP 编译所需的依赖项:

brew install autoconf bison re2c libxml2 openssl@3 libiconv icu4c bzip2 readline krb5 curl

下载 PHP 源代码

PHP 官方网站下载源码包,或者使用 wget

wget https://www.php.net/distributions/php-8.3.9.tar.gz tar -xvf php-8.3.9.tar.gz cd php-8.3.9

编写配置脚本

创建一个名为 configure_php.sh 的脚本文件,并写入以下内容:

#!/bin/bash  # 清理之前的编译结果 make clean rm -rf config.cache  # 设置PKG_CONFIG_PATH export PKG_CONFIG_PATH="/opt/homebrew/opt/krb5/lib/pkgconfig:/opt/homebrew/opt/openssl@3/lib/pkgconfig:/opt/homebrew/opt/libiconv/lib/pkgconfig:/opt/homebrew/opt/icu4c/lib/pkgconfig:/opt/homebrew/opt/readline/lib/pkgconfig:$PKG_CONFIG_PATH"  # 设置CFLAGS和LDFLAGS,确保不重复 export CFLAGS="-I/opt/homebrew/opt/krb5/include -I/opt/homebrew/opt/bzip2/include -I/opt/homebrew/opt/libiconv/include -I/opt/homebrew/opt/icu4c/include -I/opt/homebrew/opt/readline/include" export LDFLAGS="-L/opt/homebrew/opt/krb5/lib -L/opt/homebrew/opt/bzip2/lib -L/opt/homebrew/opt/libiconv/lib -L/opt/homebrew/opt/icu4c/lib -L/opt/homebrew/opt/readline/lib"  # 运行配置脚本 ./configure \ --prefix=/usr/local/php \ --with-config-file-path=/usr/local/php/etc \ --with-config-file-scan-dir=/usr/local/php/etc/php.d \ --enable-bcmath \ --enable-calendar \ --enable-exif \ --enable-fpm \ --enable-intl \ --enable-mbstring \ --enable-mysqlnd \ --enable-opcache \ --enable-pcntl \ --enable-soap \ --enable-sockets \ --with-bz2=/opt/homebrew/opt/bzip2 \ --with-curl \ --with-freetype \ --with-jpeg \ --with-kerberos=/opt/homebrew/opt/krb5 \ --with-libxml \ --with-mysqli \ --with-openssl=/opt/homebrew/opt/openssl@3 \ --with-pdo-mysql \ --with-pdo-sqlite \ --with-readline=/opt/homebrew/opt/readline \ --with-xsl \ --with-zlib \ --with-iconv=/opt/homebrew/opt/libiconv

运行配置脚本

赋予脚本执行权限并运行它:

chmod +x configure_php.sh ./configure_php.sh

运行测试

建议在安装之前运行测试:

make test

编译和安装

运行以下命令进行编译和安装:

make -j$(sysctl -n hw.ncpu) sudo make install

安装完成

Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20230831/ Installing PHP CLI binary:        /usr/local/php/bin/ Installing PHP CLI man page:      /usr/local/php/php/man/man1/ Installing PHP FPM binary:        /usr/local/php/sbin/ Installing PHP FPM defconfig:     /usr/local/php/etc/ Installing PHP FPM man page:      /usr/local/php/php/man/man8/ Installing PHP FPM status page:   /usr/local/php/php/php/fpm/ Installing phpdbg binary:         /usr/local/php/bin/ Installing phpdbg man page:       /usr/local/php/php/man/man1/ Installing PHP CGI binary:        /usr/local/php/bin/ Installing PHP CGI man page:      /usr/local/php/php/man/man1/ Installing build environment:     /usr/local/php/lib/php/build/ Installing header files:          /usr/local/php/include/php/ Installing helper programs:       /usr/local/php/bin/   program: phpize   program: php-config Installing man pages:             /usr/local/php/php/man/man1/   page: phpize.1   page: php-config.1 Installing PDO headers:           /usr/local/php/include/php/ext/pdo/

验证安装

安装完成后,检查 PHP 的版本和已启用的扩展:

/usr/local/php/bin/php -v /usr/local/php/bin/php -m

配置 PHP 环境

为了方便使用,将 PHP 二进制文件添加到系统的 PATH 中:

echo 'export PATH="/usr/local/php/bin:$PATH"' >> ~/.zshrc source ~/.zshrc

验证 PATH

重新打开终端或运行 source 命令后,验证 PHP 是否在 PATH 中:

php -v

你应该能够看到 PHP 版本信息。

相关内容

热门资讯

两秒就懂!炸金花房卡链接在哪买... 微信游戏中心:炸金花房卡,添加微信【71319951】,进入游戏中心或相关小程序,搜索“微信炸金花房...
可以自建房间的金花房卡详解/微... 金花是一款非常受欢迎的棋牌游戏,咨询房/卡添加微信:86909166许多玩家在游戏中会购买房卡来享受...
ia实测“拼三张金花房卡找谁购... 皇豪互娱是一款非常受欢迎的棋牌游戏,咨询房/卡添加微信:86909166许多玩家在游戏中会购买房卡来...
两秒就懂!微信斗牛购买房卡方法... 微信游戏中心:斗牛房卡,添加微信【56001354】,进入游戏中心或相关小程序,搜索“微信斗牛房卡”...
两秒就懂!拼三张房卡购买联系方... 微信游戏中心:拼三张房卡,添加微信【66336574】,进入游戏中心或相关小程序,搜索“微信拼三张房...
微信斗牛房卡找谁买/买房卡的金... 微信斗牛是一款非常受欢迎的棋牌游戏,咨询房/卡添加微信:86909166许多玩家在游戏中会购买房卡来...
两秒就懂!如何创建牛牛房间卡,... 微信游戏中心:斗牛房卡,添加微信【71319951】,进入游戏中心或相关小程序,搜索“微信斗牛房卡”...
正版授权“哪里有卖微信炸金花房... 微信炸金花是一款非常受欢迎的棋牌游戏,咨询房/卡添加微信:86909166许多玩家在游戏中会购买房卡...
微信牛牛群哪里购买房卡/斗牛房... 斗牛是一款非常受欢迎的棋牌游戏,咨询房/卡添加微信:86909166许多玩家在游戏中会购买房卡来享受...
两秒就懂!微信上链接拼三张房卡... 微信游戏中心:拼三张房卡,添加微信【56001354】,进入游戏中心或相关小程序,搜索“微信拼三张房...
两秒就懂!微信里面炸金花房卡在... 微信游戏中心:炸金花房卡,添加微信【66336574】,进入游戏中心或相关小程序,搜索“微信炸金花房...
终于找到“微信炸金花房卡链接在... 新众亿金花是一款非常受欢迎的棋牌游戏,咨询房/卡添加微信:44346008许多玩家在游戏中会购买房卡...
一分钟推荐“金花房卡专卖店联系... 悠悠系列是一款非常受欢迎的棋牌游戏,咨询房/卡添加微信:15984933许多玩家在游戏中会购买房卡来...
两秒就懂!微信牛牛房卡在哪里买... 微信游戏中心:牛牛房卡,添加微信【71319951】,进入游戏中心或相关小程序,搜索“微信牛牛房卡”...
秒懂教程“牛牛链接房卡那里有/... 新圣游是一款非常受欢迎的棋牌游戏,咨询房/卡添加微信:15984933许多玩家在游戏中会购买房卡来享...
两秒就懂!我买炸金花房卡链接,... 微信游戏中心:炸金花房卡,添加微信【56001354】,进入游戏中心或相关小程序,搜索“微信炸金花房...
两秒就懂!玩炸金花房卡从哪里买... 微信游戏中心:炸金花房卡,添加微信【66336574】,进入游戏中心或相关小程序,搜索“微信炸金花房...
微信建房玩斗牛房卡怎么弄/炸金... 斗牛是一款非常受欢迎的棋牌游戏,咨询房/卡添加微信:86909166许多玩家在游戏中会购买房卡来享受...
两秒就懂!在哪里买炸金花微信房... 微信游戏中心:炸金花房卡,添加微信【71319951】,进入游戏中心或相关小程序,搜索“微信炸金花房...
一分钟了解“微信房卡斗牛金花有... 新琉璃金花是一款非常受欢迎的棋牌游戏,咨询房/卡添加微信:15984933许多玩家在游戏中会购买房卡...