php v8js
Posted andyChan
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php v8js相关的知识,希望对你有一定的参考价值。
本文整理自大神 Corz
1、php56
1 /datas/soft/php56/bin/php -v 2 PHP 5.6.15 (cli) 3 #https://blog.csdn.net/lzm198707/article/details/70623421?utm_source=blogxgwz3 4 yum install re2c 5 yum install v8-devel 6 cd /datas/src/ 7 wget http://pecl.php.net/get/v8js-0.1.3.tgz 8 tar -xzf v8js-0.1.3.tgz 9 cd v8js-0.1.3 10 vim v8js.cc 11 新增 #define PHP_V8_VERSION "0.1.3" 12 /datas/soft/php56/bin/phpize 13 ./configure --with-php-config=/datas/soft/php56/bin/php-config --with-v8js 14 make 15 make install 16 ll /datas/soft/php56/lib/php/extensions/no-debug-non-zts-20131226/ 17 vim /datas/soft/php56/etc/php.ini 18 新增 extension = "v8js.so" 19 /datas/soft/php56/bin/php --ri v8js
2、php72
1 /datas/soft/php72/bin/php -v 2 PHP 7.2.14 (cli) 3 4 #升python 2.7 5 6 #升git 2+ 7 8 #装gcc 4.8.2 9 10 #升级glibc 2.18 11 #https://blog.csdn.net/tty521/article/details/80939607 12 wget http://cbs.centos.org/kojifiles/packages/glibc/2.22.90/21.el7/x86_64/glibc-2.22.90-21.el7.x86_64.rpm 13 wget http://cbs.centos.org/kojifiles/packages/glibc/2.22.90/21.el7/x86_64/glibc-common-2.22.90-21.el7.x86_64.rpm 14 wget http://cbs.centos.org/kojifiles/packages/glibc/2.22.90/21.el7/x86_64/glibc-devel-2.22.90-21.el7.x86_64.rpm 15 wget http://cbs.centos.org/kojifiles/packages/glibc/2.22.90/21.el7/x86_64/glibc-headers-2.22.90-21.el7.x86_64.rpm 16 rpm -Uvh glibc-2.22.90-21.el7.x86_64.rpm 17 glibc-common-2.22.90-21.el7.x86_64.rpm 18 glibc-devel-2.22.90-21.el7.x86_64.rpm 19 glibc-headers-2.22.90-21.el7.x86_64.rpm 20 --force --nodeps 21 strings /lib64/libc.so.6 |grep GLIBC_ 22 23 #升级GLIBCXX 24 wget http://ftp.de.debian.org/debian/pool/main/g/gcc-8/libstdc++6_8.2.0-14_amd64.deb 25 ar -x libstdc++6_8.2.0-14_amd64.deb 26 yum install -y xz 27 tar -xvf data.tar.xz 28 mv /usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6.bak 29 cp usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25 /usr/lib64/ 30 ln -s /usr/lib64/libstdc++.so.6.0.25 /usr/lib64/libstdc++.so.6 31 strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX 32 33 #编译v8、v8js(能FQ跑就不会出错:https://github.com/phpv8/v8js/blob/php7/README.Linux.md) 34 #做了两个包,可以直接解压使用(https://pan.baidu.com/s/16CAFctj94fpeYIR9IZT_cQ) 35 ll v8.tar.gz 36 tar vkzxf v8.tar.gz -C / 37 ll phpext_v8js.tar.gz 38 tar vkzxf phpext_v8js.tar.gz -C / 39 vim /datas/soft/php72/etc/php.ini 40 /datas/soft/php72/bin/php --ri v8js
3、test
1 <?php 2 $v8 = new V8Js(); 3 $v8->myname = ‘test‘; 4 $JS = <<< EOT 5 func = function(name) { 6 return ‘name is ‘ + name; 7 }; 8 func(PHP.myname); 9 EOT; 10 $res = $v8->executeString($JS); 11 var_dump($res);
1 [[email protected] ~]# /datas/soft/php56/bin/php 1.php 2 string(12) "name is test" 3 [[email protected] ~]# /datas/soft/php72/bin/php 1.php 4 string(12) "name is test"
4、后续修正
1 [[email protected] ~]# ldd /bin/ls 2 -bash: /usr/bin/ldd: /usr/bin/bash: bad interpreter: No such file or directory 3 [[email protected] ~]# ll /usr/bin/bash 4 ls: cannot access /usr/bin/bash: No such file or directory 5 [[email protected] ~]# which bash 6 /bin/bash 7 [[email protected] ~]# ln -s /bin/bash /usr/bin/bash 8 [[email protected] ~]# ldd /bin/ls 9 linux-vdso.so.1 (0x00007fff30325000) 10 libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f3e8a688000) 11 librt.so.1 => /lib64/librt.so.1 (0x00007f3e8a480000) 12 libcap.so.2 => /lib64/libcap.so.2 (0x00007f3e8a27b000) 13 libacl.so.1 => /lib64/libacl.so.1 (0x00007f3e8a073000) 14 libc.so.6 => /lib64/libc.so.6 (0x00007f3e89cb7000) 15 libdl.so.2 => /lib64/libdl.so.2 (0x00007f3e89ab2000) 16 /lib64/ld-linux-x86-64.so.2 (0x00007f3e8a8b1000) 17 libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f3e89895000) 18 libattr.so.1 => /lib64/libattr.so.1 (0x00007f3e89690000)
以上是关于php v8js的主要内容,如果未能解决你的问题,请参考以下文章
如何在 XAMPP for Windows 上安装 V8Js for PHP?