简体   繁体   English

Php:在ubuntu上的laravel homestead(vagrant)上安装v8js时出错

[英]Php: Error installing v8js on laravel homestead ( vagrant ) on ubuntu

Hello i am having trouble installing v8js on laravel homestead ( vagrant ) 您好我在laravel宅基地(流浪汉)安装v8js时遇到问题

After looking at these 2 tuts 看了这两个tuts之后

1. Install v8js on Linux (works with Homestead) ! 1.在Linux上安装v8js(与Homestead一起使用)

2. Installing PHPv8js on Ubuntu ! 2.在Ubuntu上安装PHPv8js

I Fired up the below commands 我解雇了下面的命令

$ sudo apt-get install libv8-dev libv8-dbg g++ cpp
$ sudo pecl install v8js-0.1.3

Also note that i typed /opt/v8 when it asked me for the installation prefix of libv8 另请注意,当我向我询问libv8的安装前缀时,我输入了/opt/v8

Edit: As per user(s) request i am posting the error code and removing the screenshots for the same 编辑:根据用户请求我发布错误代码并删除相同的屏幕截图

Here is my error code 这是我的错误代码

When i run first command i get this error 当我运行第一个命令时,我收到此错误

$ sudo apt-get install libv8-dev libv8-dbg g++ cpp
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package libv8-dbg is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'libv8-dbg' has no installation candidate

When i run 2nd command , it asks me to provide the installation prefix of libv8 ... i type /opt/v8 and getting the below error 当我运行第二个命令时,它要求我提供libv8的安装前缀...我输入/opt/v8并得到以下错误

$ sudo pecl install v8js-0.1.3
downloading v8js-0.1.3.tgz ...
Starting to download v8js-0.1.3.tgz (17,968 bytes)
......done: 17,968 bytes
8 source files, building
running: phpize
Configuring for:
PHP Api Version:         20151012
Zend Module Api No:      20151012
Zend Extension Api No:   320151012
Please provide the installation prefix of libv8 [autodetect] : /opt/v8
building in /tmp/pear/temp/pear-build-rootlo1BwQ/v8js-0.1.3
running: /tmp/pear/temp/v8js/configure --with-php-config=/usr/bin/php-config --with-v8js=/opt/v8
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php/20151012 -I/usr/include/php/20151012/main -I/usr/include/php/20151012/TSRM -I/usr/include/php/20151012/Zend -I/usr/include/php/20151012/ext -I/usr/include/php/20151012/ext/date/lib
checking for PHP extension directory... /usr/lib/php/20151012
checking for PHP installed headers prefix... /usr/include/php/20151012
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... re2c
checking for re2c version... 0.13.5 (ok)
checking for gawk... no
checking for nawk... nawk
checking if nawk is broken... no
checking for V8 Javascript Engine... yes, shared
checking for V8 files in default path... found in /usr
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking how to run the C++ preprocessor... g++ -E
checking for V8 version... 3.14.5.9
checking how to print strings... printf
checking for a sed that does not truncate output... (cached) /bin/sed
checking for fgrep... /bin/grep -F
checking for ld used by cc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking for gawk... (cached) nawk
checking command to parse /usr/bin/nm -B output from cc object... ok
checking for sysroot... no
checking for mt... mt
checking if mt is a manifest tool... no
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC -DPIC
checking if cc PIC flag -fPIC -DPIC works... yes
checking if cc static flag -static works... yes
checking if cc supports -c -o file.o... yes
checking if cc supports -c -o file.o... (cached) yes
checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
checking how to run the C++ preprocessor... g++ -E
checking for ld used by g++... /usr/bin/ld -m elf_x86_64
checking if the linker (/usr/bin/ld -m elf_x86_64) is GNU ld... yes
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking for g++ option to produce PIC... -fPIC -DPIC
checking if g++ PIC flag -fPIC -DPIC works... yes
checking if g++ static flag -static works... yes
checking if g++ supports -c -o file.o... yes
checking if g++ supports -c -o file.o... (cached) yes
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... (cached) GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
configure: creating ./config.status
config.status: creating config.h
config.status: executing libtool commands
running: make
/bin/bash /tmp/pear/temp/pear-build-rootlo1BwQ/v8js-0.1.3/libtool --mode=compile g++  -I. -I/tmp/pear/temp/v8js -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootlo1BwQ/v8js-0.1.3/include -I/tmp/pear/temp/pear-build-rootlo1BwQ/v8js-0.1.3/main -I/tmp/pear/temp/v8js -I/usr/include/php/20151012 -I/usr/include/php/20151012/main -I/usr/include/php/20151012/TSRM -I/usr/include/php/20151012/Zend -I/usr/include/php/20151012/ext -I/usr/include/php/20151012/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /tmp/pear/temp/v8js/v8js.cc -o v8js.lo
libtool: compile:  g++ -I. -I/tmp/pear/temp/v8js -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootlo1BwQ/v8js-0.1.3/include -I/tmp/pear/temp/pear-build-rootlo1BwQ/v8js-0.1.3/main -I/tmp/pear/temp/v8js -I/usr/include/php/20151012 -I/usr/include/php/20151012/main -I/usr/include/php/20151012/TSRM -I/usr/include/php/20151012/Zend -I/usr/include/php/20151012/ext -I/usr/include/php/20151012/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/pear/temp/v8js/v8js.cc  -fPIC -DPIC -o .libs/v8js.o
/tmp/pear/temp/v8js/v8js.cc:32:40: fatal error: ext/standard/php_smart_str.h: No such file or directory
 #include "ext/standard/php_smart_str.h"
                                        ^
compilation terminated.
make: *** [v8js.lo] Error 1
ERROR: `make' failed

I've found a fix for this; 我找到了解决这个问题的方法; we should checkout the version 5.1.99 as the latest v8js build seems broken. 我们应该检查版本5.1.99,因为最新的v8js版本似乎已经破解。

Background history 背景历史

A bug has been raised to the v8 team by stacie stacie已经向v8团队提出了一个错误

Bug "unicode/uchar.h" not found while building V8 #238 also opened on Github 构建V8#238时未找到错误“unicode / uchar.h”也在Github上打开

A solution log has been provided by tiemevanveen tiemevanveen提供了解决方案日志

Current Solution 现行解决方案

The commands are as follows: 命令如下:

Install build-essential if you haven't already: 如果你还没有安装build-essential

sudo apt-get install build-essential

Install libicu-dev if you haven't already: 如果你还没有安装libicu-dev

sudo apt-get install libicu-dev
cd /tmp

Install depot_tools first (needed for source checkout) 首先安装depot_tools(源检查需要)

git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH=`pwd`/depot_tools:"$PATH"

Download v8 下载v8

fetch v8
cd v8

checkout working version: 结帐工作版:

git checkout 5.1.99
gclient sync

use libicu of operating system 使用libicu的操作系统

export GYP_DEFINES="use_system_icu=1"

Build (with internal snapshots) 构建(使用内部快照)

export GYPFLAGS="-Dv8_use_external_startup_data=0"

Force gyp to use system-wide ld.gold 强制gyp使用系统范围的ld.gold

export GYPFLAGS="${GYPFLAGS} -Dlinux_use_bundled_gold=0"
make native library=shared snapshot=on -j8

Install to /usr 安装到/ usr

sudo mkdir -p /usr/lib /usr/include
sudo cp out/native/lib.target/lib*.so /usr/lib/
sudo cp -R include/* /usr/include

... same for V8 < 5.2.51, libv8_libplatform.a is built in tools/gyp directory ...对于V8 <5.2.51,libv8_libplatform.a内置于tools / gyp目录中

echo -e "create /usr/lib/libv8_libplatform.a\naddlib out/native/obj.target/tools/gyp/libv8_libplatform.a\nsave\nend" | sudo ar -M

Compile php-v8js itself 编译php-v8js本身

cd /tmp
git clone https://github.com/phpv8/v8js.git
cd v8js
phpize
./configure
make
make test
sudo make install

Then add extension=v8js.so to your php.ini file. 然后将extension = v8js.so添加到您的php.ini文件中。

Official guide 官方指南

I ran into the same issue while installing v8js on a Ubuntu 16 VM (using vagrant/Homestead). 我在Ubuntu 16 VM(使用vagrant / Homestead)上安装v8js时遇到了同样的问题。 Instead of compiling from source, here's how I solve this issue: 而不是从源代码编译,这是我如何解决这个问题:

 1. sudo apt-get install g++ cpp 
 2. sudo add-apt-repository
 3. sudo apt-get update 
 4. sudo pecl install v8js
 5. sudo service php7.1-fpm restart

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM