v8js 是一個 PHP Extension , 主要用在 PHP 中提供 V8 這個 Javascript 引擎功能。
安裝環境
CentOS Linux release 7.6
PHP 7.3.13
安裝方式
安裝軟體開發工具
# yum groupinstall "Development Tools"
安裝GCC 8.3
# wget https://www.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-8.3.0/gcc-8.3.0.tar.gz # tar zxvf gcc-8.3.0.tar.gz # ./contrib/download_prerequisites # ./configure --disable-multilib --enable-languages=c,c++ # make # make install # export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/usr/local/lib64:/usr/lib64 # echo "/usr/local/lib64/" > /etc/ld.so.conf.d/gcc-8.3.0.x86_64.conf # rm -f /usr/local/lib64/libstdc++.so.6.0.25-gdb.py # ldconfig
Add depot_tools
# cd /usr/local
# git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
# export PATH=`pwd`/depot_tools:"$PATH"
Install v8
# cd /usr/local/src
# fetch v8
# cd v8
# git checkout 7.5.288.23
# gclient sync
# 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
# mkdir -p /opt/v8/{lib,include}
# cp -v out.gn/library/lib*.so out.gn/library/*_blob.bin out.gn/library/icudtl.dat /opt/v8/lib/
# cp -vR include/* /opt/v8/include/
# ldconfig
Install php-v8js
安裝過程中會要你輸入libv8位置, 輸入/opt/v8
# pecl install v8js 加入php extension
# echo "extension=v8js.so" > /etc/php.d/50-v8js.ini