How to install php v8js on Mac?

纵饮孤独 提交于 2019-12-06 05:15:03

问题


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


回答1:


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

install the engine
$ brew install v8

install dependency for the PECL extension
$ brew install autoconf

install/configure PEAR and PECL:

  • 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. type 1 and press enter.
    2. enter /usr/local/pear
    3. press enter.
    4. type 4 and press enter
    5. enter /usr/local/bin
    6. press enter.

update/upgrade PEAR/PECL:

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

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 #if this step fails you can try to install anyway. should work.
$ 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.)

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

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

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 (located at: /etc/apache2):
Uncomment the following line: LoadModule php7_module libexec/httpd/libphp7.so

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>

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



来源:https://stackoverflow.com/questions/43814231/how-to-install-php-v8js-on-mac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!