本帖最后由 yaojiu 于 2023-5-5 20:31 编辑
1.安装依赖
- yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
复制代码
2.构建最新的C ++编译器
您可以使用检查当前版本。如果有gcc -v在运行,最低版本8.3.0
- sudo yum install bzip2
- cd /usr/local/src
- wget http://d1.cmdtz.com/dll/gcc-8.3.0.tar.gz
- tar zxf gcc-8.3.0.tar.gz
- cd gcc-8.3.0/
- ./contrib/download_prerequisites
- ./configure --disable-multilib --enable-languages=c,c++
- make
- sudo make install
- export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/usr/local/lib64:/usr/lib64
复制代码
3.安装V8
- # 添加 depot_tools
- cd /usr/local
- git clone https://chromium.googlesource.com/chromium/tools/depot_tools
- export PATH=`pwd`/depot_tools:"$PATH"
复制代码- # 拉取 v8
- cd /usr/local/src
- fetch v8
- cd v8
- git checkout 7.5.288.23 # v8_版本号
- gclient sync
- ./build/install-build-deps.sh
- gn gen out.gn/library --args='use_custom_libcxx=false is_component_build=true is_debug=false target_cpu="x64" use_goma=false goma_dir="None" v8_enable_backtrace=true v8_enable_disassembler=true v8_enable_object_print=true v8_enable_verify_heap=true'
- ninja -C out.gn/library libv8.so
复制代码- # 移动文件至 /opt/v8
- sudo mkdir -p /opt/v8/{lib,include}
- sudo cp -v out.gn/library/lib*.so out.gn/library/*_blob.bin out.gn/library/icudtl.dat /opt/v8/lib/
- sudo cp -vR include/* /opt/v8/include/
复制代码 2:安装v8js-2.1.1
- wget https://pecl.php.net/get/v8js-2.1.1.tgz
复制代码- phpize #如报错,请使用 /www/server/php/72/bin/phpize
复制代码- ./configure --with-php-config=/www/server/php/72/bin/php-config --with-v8js #注意php的目录自行更换 如果这个报错,就用下面那个
复制代码- #上面那条命令报错再用这个 ./configure --with-v8js=/opt/v8 LDFLAGS="-lstdc++" CPPFLAGS="-DV8_COMPRESS_POINTERS" --with-php-config=/www/server/php/72/bin/php-config
复制代码
3,在php7.2配置文件合适的地方加上
重启PHP后查看phpinfo可以看到其中已经包含v8js扩展
|