2019年12月

首先检查您的PHP是线程安全性的还是非安全性的,因为我们需要知道要下载正确的模块。你可以在Windows中运行一个简单的命令来检查这个。代码如下:

php -i | findstr "Thread"

如果结果输出是Thread Safety => enabled,那说明你的PHP版本是线程安全性的,反之亦然。
当然你也可以新建个PHP文件,用php_info();来获取你PHP的信息。

接下来,在Jan-E这里下载完整的编译好的PHP版本:
https://www.apachelounge.com/viewtopic.php?t=6359
然后你可以从里面提取出你需要的文件,将它们解压到各自的文件夹中:
\php\ 文件夹:

  • v8.dll
  • v8_libbase.dll
  • v8_libplatform.dll
  • icui18n.dll (php7)
  • icuuc.dll (php7)

\php\ext\文件夹:

  • php_v8js.dll

还有最后一步,配置你的php.ini文件:

; V8 Javascript Engine Module
extension=php_v8js.dll

最后重启你的服务就可以了!!!

提供个简单的例子:

<?php

$v8 = new V8Js();

/* basic.js */
$JS = <<< EOT

var string1 = 'Hello' + ' ' + 'World!';
len = print(string1+"\\n");
var string2 = 'Hello' + ' ' + 'World2!';
len2 = print(string2+"\\n");
string1+","+string2;
EOT;

try {
  $temp = $v8->executeString($JS, 'basic.js');
  $temp = explode(",",$temp);
  print_r($temp);
} catch (V8JsException $e) {
  print_r($e);
}

运行结果如下:

[Running] php "e:worktest.php"
Hello World!
Hello World2!
Array
(

[0] => Hello World!
[1] => Hello World2!
)

[Done] exited with code=0 in 0.622 seconds
按照上面的方法设置后在windows + iis + php 环境可用。
如果使用的是apache,则需要把复制到\php\同目录下的几个文件复制到apache\bin目录下才行。

创建frps服务配置文件

cat /etc/systemd/system/multi-user.target.wants/frps.service

“multi-user.target.wants”是一个服务组目录,所有放在该目录下的服务系统都会开机启动

写入内容

[Unit]
Description=Frp Server Service
After=network.target

[Service]
Type=simple
User=nobody
Restart=on-failure
RestartSec=5s
ExecStart=/usr/local/src/frp/frp_0.30.0_linux_amd64/frps -c /usr/local/src/frp/frp_0.30.0_linux_amd64/frps.ini
ExecStop=/usr/local/src/frp/frp_0.30.0_linux_amd64/frps stop

[Install]
WantedBy=multi-user.target

修改配置文件后重启

修改配置文件以后,需要重新加载配置文件,然后重新启动相关服务。

# 重新加载配置文件
$ sudo systemctl daemon-reload
# 重启相关服务
$ sudo systemctl restart frps
# 查看指定服务的状态
$ sudo systemctl status frps
# 列出所有服务的开机状态
$ sudo systemctl list-unit-files       

查看frps进程相关信息

ps -ef | grep frps