macos 安装 V8JS 方法
- 下面隐藏的是我整理完整流程 在
macOS
Monterey
12.6.8
php@7.4
安装完成
安装好的结果
PHP Version 7.4.33
v8js
V8 Javascript Engine enabled
V8 Engine Compiled Version 11.6.189.18
V8 Engine Linked Version 11.6.189.18
Version 2.1.2
mac苹果操作系统下安装v8js扩展完整流程如下
Mac安装PHP的v8js扩展 关键代码是这里
下面是网络找的参考 看能否解决你的问题 未解决可以看看上面
的
libv8 must be version 4.6.76 or greater
[V8 built with gn] configure: error: could not determine libv8 version
brew install v8@3.15
gem install libv8 -v '3.16.14.3' -- --with-system-v8
gem install therubyracer -v '0.12.3' -- --with-v8-dir=/usr/local/opt/v8@3.15
bundle install
echo 'export PATH="/usr/local/opt/v8@3.15/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
export LDFLAGS="-L/usr/local/opt/v8@3.15/lib"
export CPPFLAGS="-I/usr/local/opt/v8@3.15/include"
export PATH="/usr/local/opt/php@7.4/bin:$PATH"
export PATH="/usr/local/opt/php@7.4/sbin:$PATH"
export LDFLAGS="-L/usr/local/opt/php@7.4/lib"
export CPPFLAGS="-I/usr/local/opt/php@7.4/include"
/usr/local/opt/php@7.4/bin/pecl install v8js
以上无效 参考下面的
Download older formula of v8 (ver 8.6.395.23):
wget https://raw.githubusercontent.com/Homebrew/homebrew-core/138b52806dad359b9f2c8da1de451b787a763944/Formula/v8.rb
Install v8 from the downloaded formula:
brew install v8.rb
If brew can't install v8 from the downloaded v8.rb file, you can try to build version 8.6.395.23 of v8 by yourself, see the guide "Compiling older version v8" above in this thread.
Make required matching phpv8js build folder structure:
mkdir -p /usr/local/Cellar/v8/8.6.395.23/libexec/lib
cp /usr/local/Cellar/v8/8.6.395.23/libexec/* /usr/local/Cellar/v8/8.6.395.23/libexec/lib
Download phpv8js:
git clone https://github.com/phpv8/v8js
cd v8js
Build phpv8js:
phpize
The following command patches file v8js_v8object_class.cc, otherwise you get 1 failed test. See 94db71e - Thanks @nvq247
sed -i -e '132s/retval/object/g' v8js_v8object_class.cc
./configure --with-v8js="/usr/local/Cellar/v8/8.6.395.23/libexec" LDFLAGS="-lstdc++" CPPFLAGS="-DV8_COMPRESS_POINTERS"
make
make test
make install
Add line extension="v8js.so" to beginning of php.in file:
php --ini
nano {path to php.ini}
brew services restart php
发表评论 取消回复