1、环境准备
centos6.9
php5.4 #如果安装的php版本高于5.4,要降级版本至5.4
libv8版本3.15.5
v8js版本0.1.3
此扩展要在国外的服务器上安装。因为扩展及相关依赖都是从google上下载的,国内的服务器无法下载
2、安装依赖
安装 re2c
yum install re2c
编译libv8.so
wget https://github.com/v8/v8-git-mirror/archive/3.15.5.tar.gz
cd v8-3.15.5/build
git clone https://chromium.googlesource.com/external/gyp
cd ..
make native
make x64.release library=shared
cp /app/v8-3.15.5/out/x64.release/lib.target/libv8.so /usr/lib/
cp /app/v8-3.15.5/include/v8* /usr/include/
3、安装v8js-0.1.3
从http://pecl.php.net/v8js下载v8js的源代码包
wget http://pecl.php.net/get/v8js-0.1.3.tgz
tar -xvf v8js-0.1.3.tgz
cd v8js-0.1.3
phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-v8js
make && make install
4、配置php.ini文件
vim /usr/local/php/etc/php.ini
extension=v8js.so
service php-fpm restart
参考:
https://blog.csdn.net/chinboy2010/article/details/8006289
https://www.ctolib.com/topics-23172.html
https://github.com/reactjs/React.NET/issues/289