如何在 Mac 上安装 php v8js? [英] How to install php v8js on Mac?

查看:42
本文介绍了如何在 Mac 上安装 php v8js?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要 ReactJs 应用程序的 php v8JS 扩展.有人可以给我完整的安装说明吗?我使用的是 php 5.6 和 Xampp.

Hi i need php v8JS extension for ReactJs app. Can someone give me full installation instruction? I am using php 5.6 and Xampp.

推荐答案

让我先说一句:如果您正在寻找一种更短的方法来做到这一点,那么它不存在.

Let me preface this by saying: if you're looking for a shorter way to do this, it does not exist.

安装引擎
$ brew install v8

为 PECL 扩展安装依赖项
$ brew install autoconf

install dependency for the PECL extension
$ brew install autoconf

安装/配置 PEAR 和 PECL:

install/configure PEAR and PECL:

  • 首先下载 go-pear.phar 文件(您也可以使用浏览器手动下载)
    $ curl -O https://pear.php.net/go-pear.phar
  • 配置 PEAR 进行安装:
    $ php -d detect_unicode=0 go-pear.phar
    当上面的命令提示时(前三步是更改安装基础,后三步是更改二进制目录):
  • first download go-pear.phar file (you can also just download it manually using your browser)
    $ curl -O https://pear.php.net/go-pear.phar
  • configure PEAR for installation:
    $ php -d detect_unicode=0 go-pear.phar
    when prompted by the command above (the first three steps are to change the installation base and the last 3 are to change the binaries directory):
  1. 输入 1 并按 Enter.
  2. 进入/usr/local/pear
  3. 按回车键.
  4. 输入 4 并按回车
  5. 进入/usr/local/bin
  6. 按回车键.

更新/升级 PEAR/PECL:

update/upgrade PEAR/PECL:

$ sudo pear channel-update pear.php.net
$ sudo pecl channel-update pecl.php.net
$ sudo pear upgrade-all

从 github & 获取 V8Js PECL 扩展安装它

Grab V8Js PECL Extension from github & install it

$ cd ~
<代码>$ mkdir tmp &&cd tmp
$ git clone https://github.com/phpv8/v8js
$ cd v8js
$ phpize
$ ./configure CXXFLAGS="-Wno-c++11-narrowing"
$ make
$ make test #如果这一步失败你可以尝试安装.应该可以工作.
$ make install

(关于 Capitan 用户和 make install 命令的注意事项:如果您收到不允许操作"错误,您将必须禁用系统完整性保护,如这里 - 请务必先阅读为什么要实施此限制.)

(note on Capitan users and the make install command: if you are getting an 'operation not permitted' error you will have to disable the system integrity protection as described here - be sure to read on why this restriction is in place to begin with.)

确保您的 php.ini 文件(位于:/etc/php.ini)具有以下内容:extension=v8js.so

make sure your php.ini file (located at: /etc/php.ini) has the following: extension=v8js.so

此时,php命令行上应该可以使用v8js了,查看:$ php -i |grep v8js

at this point, v8js should be available on the php command line, check: $ php -i | grep v8js

奖励:上面应该回答了有关如何安装 v8js 的问题,但您必须进一步使其在 Mac 的内置 Apache 服务器上运行.

Bonus: the above should answer the question on how to get v8js installed but you have to go further to make it work on Mac's built-in Apache Server.

Apache httpd.conf(位于:/etc/apache2):
取消注释以下行:LoadModule php7_module libexec/httpd/libphp7.so

Apache httpd.conf (located at: /etc/apache2):
Uncomment the following line: LoadModule php7_module libexec/httpd/libphp7.so

将以下内容添加到 httpd.conf 文件中:

Add the following to the httpd.conf file:

<IfModule mod_php7.c>
# If php is turned on, we respect .php and .phps files.
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

# Since most users will want index.php to work we
# also automatically enable index.php
<IfModule mod_dir.c>
    DirectoryIndex index.html index.php
</IfModule>

保存文件.并重新启动服务器:sudo apachectl graceful(或者如果它没有运行就启动它)

save the file. and restart the server: sudo apachectl graceful (or just start it if its not running)

这篇关于如何在 Mac 上安装 php v8js?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆