Enable sqlite3 FTS5 for PHP - php

I'm trying to use SQLite3 FTS5 (full-text search) with PHP on CentOS.. but I couldn't get it successfully after so much time trying.
I'm building a loadable FTS5 Extension for SQlite and tried the following steps (from docs)
in the server terminal (SSH) :
$ yum install libsqlite3x-devel
$ wget -c http://www.sqlite.org/src/tarball/SQLite-trunk.tgz?uuid=trunk -O SQLite-trunk.tgz
$ tar -xzf SQLite-trunk.tgz
$ cd SQLite-trunk
$ ./configure && make fts5.c
$ gcc -g -fPIC -shared fts5.c -o fts5.so
But I'm having the following error in the last step:
fts5_index.c:732:11: error: ‘SQLITE_PREPARE_PERSISTENT’ undeclared (first use in this function)
fts5_index.c:732:37: error: ‘SQLITE_PREPARE_NO_VTAB’ undeclared (first use in this function)
fts5_main.c:888:29: error: ‘SQLITE_PREPARE_PERSISTENT’ undeclared (first use in this function)
fts5_main.c:1029:31: error: ‘SQLITE_PREPARE_PERSISTENT’ undeclared (first use in this function)
fts5_storage.c:139:15: error: ‘SQLITE_PREPARE_PERSISTENT’ undeclared (first use in this function)
fts5_storage.c:140:41: error: ‘SQLITE_PREPARE_NO_VTAB’ undeclared (first use in this function)
The file fts5.so is not produced so I can't use it in the server
So do you have any idea how to fix this error and produce fts5.so file successfully

I found that I have to generate header files before the last step
so the full steps looks like this:
$ yum install libsqlite3x-devel
$ wget -c http://www.sqlite.org/src/tarball/SQLite-trunk.tgz?uuid=trunk -O SQLite-trunk.tgz
$ tar -xzf SQLite-trunk.tgz
$ cd SQLite-trunk
$ ./configure
$ make fts5.c sqlite3.h sqlite3ext.h
$ gcc -g -fPIC -shared fts5.c -o fts5.so
Then I had to load the fts5.so as loadable extension for sqlite
1- Copy the fts5.so file to a new folder on server /sqlite_ext
$ mkdir /sqlite_ext
$ cp fts5.so /sqlite_ext
2- Edit sqlite3.extension_dir in php.ini to point to the same folder like this
sqlite3.extension_dir = "/sqlite_ext"
3- Then in my php file, load the extension :
$db->loadExtension('fts5.so');
Update :
It's better to update server's SQLite as a whole with --enable-fts5 option
$ wget -c https://www.sqlite.org/2019/sqlite-autoconf-3280000.tar.gz
$ tar -xzf sqlite-autoconf-3280000.tar.gz
$ cd sqlite-autoconf-3280000
$ ./configure --enable-fts5 --prefix=/usr --disable-static CFLAGS="-g -O2 -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_ENABLE_UNLOCK_NOTIFY=1 -DSQLITE_SECURE_DELETE=1 -DSQLITE_SOUNDEX"
$ make
$ make install
Now the latest SQLite is installed for the server but not for PHP, let's do it for PHP
$ mv aclocal.m4 config.m4
$ phpize
Check for your SQLite version in server using $ sqlite3 --version and in PHP using phpinfo();
*notice: the link mentioned in the first step is for the latest sqlite-autoconf amalgamation at the time of this answer. there maybe a more recent version for you . check here

Related

Trying to upgrade SQLite on Amazon EC2

I need SQLite minimum version 3.8 to support a MediaWiki install on Amazon EC2. Amazon Linux is based on CentOS and the latest version available in the yum repository is SQLite 3.7.17.
The downloads available from sqlite.org don't include 64-bit Linux. There is a GitHub repository that has a prebuilt 64-bit version, however it's only the command line version. I put it at /usr/bin:
$ which sqlite3
/usr/bin/sqlite3
$ sqlite3 --version
sqlite3: /lib64/libtinfo.so.5: no version information available (required by sqlite3)
3.26.0 2018-12-01 12:34:55 bf8c1b2b7a5960c282e543b9c293686dccff272512d08865f4600fb58238b4f9
But MediaWiki still complains I have SQLite 3.7.17 installed. When I test it I get:
$ cat x.php
<?php
print_r(SQLite3::version());
?>
Run it:
$ php7 x.php
Array
(
[versionString] => 3.7.17
[versionNumber] => 3007017
)
I am guessing this is because of these libraries:
$ sudo find / -name "libsqlite*"
/usr/lib64/libsqlite3.so.0
/usr/lib64/libsqlite3.so.0.8.6
How can I download/rebuild or otherwise install a later version of these SQLite libraries?
The easiest option I found was to build it myself. Tested on Amazon Linux release 2 (Karoo).
Download the latest source code with the configure script from here. Currently this is:
curl https://www.sqlite.org/2020/sqlite-autoconf-3320300.tar.gz | tar xzf -
Go into the created directory and create the Makefile with our system dependant options:
cd ./sqlite-autoconf-3320300 && ./configure
Build the binary
make
Install it
sudo make install
Clean up
cd .. && rm -r ./sqlite-autoconf-3320300
Note: It's far from ideal to do this without a proper RPM package. If you update sqlite through yum, you will overwrite you manually built version.
Adding on to #halbgut answer, with some changes:
Download the latest source code with the configure script from here. Currently this is:
curl https://www.sqlite.org/2020/sqlite-autoconf-3320300.tar.gz | tar xzf -
Go into the created directory and create the Makefile with our system dependent options:
cd ./sqlite-autoconf-3320300 && ./configure
Build the binary
make
Install it
sudo make install
Now, you have created the sqlite3 file. You need to replace them everywhere you find the file sqlite3.
To find all these places - run the following command:
whereis sqlite3
sqlite3: /usr/bin/sqlite3 /usr/local/bin/sqlite3 /usr/include/sqlite3.h /opt/c9/bin/sqlite3 /usr/share/man/man1/sqlite3.1.gz
Now within the sqlite source folder ./sqlite-autoconf-3320300, find the sqlite3, sqlite3.h files and replace with the following cp command
sudo cp sqlite-autoconf-3320300/sqlite3 /usr/local/bin/sqlite3
sudo cp sqlite-autoconf-3320300/sqlite3 /usr/local/bin/sqlite3
sudo cp sqlite-autoconf-3320300/sqlite3 /opt/c9/bin/sqlite3 {I am using c9, hence this file, figure out what file is in the opt/ dir)
sudo cp sqlite-autoconf-3320300/sqlite3.h /usr/include/sqlite3.h
Once done, you would have upgraded both env and python-env. Now you need to just define the path to it. For it, use the local/lib in usr.
export LD_LIBRARY_PATH="/usr/local/lib"
Now you should have this :
$ python -c "import sqlite3; print(sqlite3.sqlite_version)"
3.23.3
$ sqlite3 --version
3.32.3
If you just need the sqlite3 binary, the SQLite amalgamation also works perfectly on Amazon Linux 2. For SQLite 33.9.04 (or others from the SQLite Download section):
wget "https://www.sqlite.org/2022/sqlite-amalgamation-3390400.zip"
unzip "sqlite-amalgamation-3390400.zip"
cd "sqlite-amalgamation-3390400"
gcc shell.c sqlite3.c -lpthread -ldl -lm -o sqlite3
And then use it as you would any other software compiled from source:
ln -n ./sqlite3 ${wherever}/sqlite3
export PATH="${wherever}:$PATH"
SQLite docs give a good explanation of further options if you need them.
Get the latest sqlite3 download link from https://www.sqlite.org/download.html
and update the link given in the WGET bash command example shown below.
Example:
wget https://www.sqlite.org/2022/sqlite-tools-linux-x86-3400000.zip
unzip sqlite-tools*.zip
cd sqlite-tools*
sudo cp sql* /usr/local/bin/ # Usually this directory is empty, so no need to worry about overwriting files
cd ~
sudo yum update -y
sudo amazon-linux-extras install epel -y
sudo yum install glibc.i686 -y
sqlite3 --version

PHP oci8 won't install through pecl: "fatal error: oci8_dtrace_gen.h"

I am trying to connect my fedora 25 webserver - php to Oracle db.
To do this I need to pecl install oci8.
However I get this error:
/bin/sh /var/tmp/pear-build-roottqYEC6/oci8-2.1.4/libtool --mode=compile cc -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-roottqYEC6/oci8-2.1.4/include -I/var/tmp/pear-build-roottqYEC6/oci8-2.1.4/main -I/var/tmp/oci8 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/oracle/12.1/client64 -DHAVE_CONFIG_H -g -O2 -c /var/tmp/oci8/oci8.c -o oci8.lo
libtool: compile: cc -I. -I/var/tmp/oci8 -DPHP_ATOM_INC -I/var/tmp/pear-build-roottqYEC6/oci8-2.1.4/include -I/var/tmp/pear-build-roottqYEC6/oci8-2.1.4/main -I/var/tmp/oci8 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/include/oracle/12.1/client64 -DHAVE_CONFIG_H -g -O2 -c /var/tmp/oci8/oci8.c -fPIC -DPIC -o .libs/oci8.o
In file included from /var/tmp/oci8/oci8.c:49:0:
/var/tmp/oci8/php_oci8_int.h:46:29: fatal error: oci8_dtrace_gen.h: No such file or directory
#include "oci8_dtrace_gen.h"
^
compilation terminated.
Makefile:196: recipe for target 'oci8.lo' failed
make: *** [oci8.lo] Error 1
ERROR: `make' failed
I do not know what to do. I've searched everywhere for a solution, and I can only find outdated articles.
Any help much appreciated!
It seems that your PHP was built with DTrace support enabled. Due to some limitations with the PHP build & config files, the PECL OCI8 install needs a hint to also build with DTrace:
$ export PHP_DTRACE=yes
$ pecl install oci8
This is mentioned in http://php.net/manual/en/oci8.dtrace.php
Note: I got the same oci8_dtrace_gen.h but 'sudo yum install systemtap-sdt-devel && export PHP_DTRACE=yes && pecl install oci8' didnt help (added the systemtap-stp-devel step as comment below reminded me I did read in some article that I had to install it for DTRACE ).
I had to manually build which some articles recommended:
$ sudo yum install php-pear php-devel
$ pear download pecl/oci8
$ tar xvzf oci8-2.1.8.tgz
$ cd oci8-2.1.8/
$ phpize
# make sure of the instantclient path below... mine was version 18.3 so it was located in this folder... Also make note some tutorials ask for the ORACLE_HOME folder which theoretically is /usr/lib/oracle/18.3/client64 but if its instantclient then put the lib folder underneath it (worked for me at least:)
$ ./configure --with-oci8=instantclient,/usr/lib/oracle/18.3/client64/lib
$ make
$ make install
#NOW an .so file built in: /usr/lib64/php/modules/oci8.so
#THIS STEP NOT NEEDED if SELinux disabled on your server/box, but if SELinux is enabled run: setsebool -P httpd_execmem 1
#NOW add: extension=oci8.so at the bottom of your php.ini file (probab in /etc/php.ini)
$ sudo service httpd restart
# note that you can also install PDO_OCI to connect to oracle but its very old and not as good as OCI8 lib (and maybe dependent on having OCI8 anyway)
Beforehand you may want to test and make sure the instantclient libs installed correctly by trying sqlplus:
$ sudo rpm -ivh oracle-instantclient18.3-basic-18.3.0.0.0-1.x86_64.rpm
$ sudo rpm -ivh oracle-instantclient18.3-sqlplus-18.3.0.0.0-1.x86_64.rpm
$ sudo rpm -ivh oracle-instantclient18.3-devel-18.3.0.0.0-1.x86_64.rpm
$ sudo rpm -ivh oracle-instantclient18.3-tools-18.3.0.0.0-1.x86_64.rpm
#add your TNSNAMES connection string info below to this file
$ sudo touch /usr/lib/oracle/18.3/client64/network/admin/tnsnames.ora
$ vi ~/.bash_profile
#add below info to bash_profile to test sqlplus
ORACLE_HOME=/usr/lib/oracle/18.3/client64
export ORACLE_HOME
PATH=$PATH:$ORACLE_HOME/bin
export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib
export LD_LIBRARY_PATH
TNS_ADMIN=$ORACLE_HOME/lib/network/admin
export TNS_ADMIN
# log out and log back in and test, sqlplus should have access to TNS_ADMIN now
$ sqlplus username/pass#TNSNAMES_SHORTCUT_OF_THE_DB_CONNECTION
and afterwards, you may want to check your phpinfo() output to make sure apache has access to ORACLE_HOME, TNS_ADMIN, LD_LIBRARY_PATH vars in its Environment section (i defined these in /etc/sysconfig/httpd).
Then you can test OCI with a simple script like this... I put various connection string formats which worked for me that you can uncomment and test (some dependent on EZCONNECT style or assuming you have TNS_ADMIN setup correctly. 1st uncommented $db one is the easiest):
<?php
//works
// ... as long as $TNS_NAMES is defined and passed to apache correctly (using /etc/sysconfig/httpd to add the var.... after defined ORACLE_HOME in there, DONT USE $ORACLE_HOME to define the rest of the vars like for TNS_ADMIN... aka dont do this: TNS_ADMIN=$ORACLE_HOME/lib/network/admin ... use full path: TNS_ADMIN=/usr/lib/oracle/18.3/client64/lib/network/admin )
$username = "myusername";
$password = "mypassword\$2"; //note: may need to escape some chars here like for me i had to escape $ with a backslash
$db = "TNSNAMES_SHORTCUT_OF_THE_DB_CONNECTION";
// works
/*
$db = <<<EOT
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)
(HOST=mydbhost.example.com)
(PORT=1521)
)
(CONNECT_DATA=
(SERVER=dedicated)
(SERVICE_NAME=name.of.the.service.here)
)
)
EOT;
*/
//works, double-check with your DBA as maybe you want to connect to a specific SID or different connection string format
//$db = "(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = mydbhost.example.com)(PORT = 1521)))(CONNECT_DATA=(SERVER=dedicated)(SERVICE_NAME=name.of.the.service.here)))";
// works
// ezconnect format: username/password#[//]host[:port][/service_name] (username and pass are already in oci_connect function so removed from below)
//$db = '//mydbhost.example.com:1521/name.of.the.service.here';
$conn = oci_connect( $username, $password, $db);
if (!$conn) {
$m = oci_error();
trigger_error(htmlentities($m['message']), E_USER_ERROR);
}
$sql = "select SYSDATE from DUAL";
$stid = oci_parse($conn, $sql);
oci_execute($stid);
while ($row = oci_fetch_array ($stid)) {
echo $row[0]."<br>";
}
oci_free_statement($stid);
oci_close($conn);
I couldn't get the RPM package installs to work on my Centos 6 server, so I tried manual install but was running into a number of problems, including the issue with the DTRACE option.
Here is what I did to upgrade OCI8 (after upgrade to PHP 7.3 broke the webapp).
Hopefully this might be of use to someone else.
Download the Instant Client Zip files from Oracle and extract on the server (I had top download them from a browser then SCP them to the server):
cd /u01/app/oracle/product/InstClient/
unzip instantclient-basic-linux.x64-11.2.0.4.0.zip
This creates instantclient_11_2 sub dir, unzip the SDK to the same location:
unzip instantclient-sdk-linux.x64-11.2.0.4.0.zip
Edit /etc/sysconfig/httpd and point LD_LIBABRY_PATH to new instantclient_11_2 home.
Sym links the library:
ln -s /u01/app/oracle/product/InstClient/instantclient_11_2/libclntsh.so.11.1 /u01/app/oracle/product/InstClient/instantcliet_11_2/libclntsh.so
Get the oci8 source package from php.net:
wget https://pecl.php.net/get/oci8-2.2.0.tgz
tar xf oci8-2.2.0.tgz
cd oci8-2.2.0
phpize
Needed to upgrade autoconf and install systemtap-sdt-devel
wget http://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gz
gunzip autoconf-latest.tar.gz
tar xf autoconf-latest.tar
cd autoconf-2.69
./configure
make
make install
yum install systemtap-sdt-devel
Continue with OCI8:
cd ../oci8-2.2.0
phpize
phpize 7.3
export PHP_DTRACE=yes
./configure --with-oci8=instantclient,/u01/app/oracle/product/InstClient/instantclient_11_2 --with-php-config=/usr/bin/php-config
make
make test
The test reported lots of FAILs but reckon due to not having correct DB login creds so continued:
make install
ls -ltr /usr/lib64/php/modules/ # check oci8.so is updated
service httpd restart
php -v # No OCI8 error reported and web app working
Something to be aware of - the default oci8 install is for PHP8. I was getting this same error, until I checked the PECL website.
Try running this instead: pecl install oci8-2.2.0
I resolved so, I made sure that it was worth dtrace --help after that I launched in terminal sudo PHP_DTRACE=yes pecl install. Then enter in this prompt “instantclient,”. After this the make should proceed, and then you just need to edit your “/etc/php.ini” file to add “extension=oci8.so” at the very bottom of the file and then restart your httpd or nginx service.

php-config shell script needed

I want to compile extension for PHP under Windows and I need to run such command:
g++ `php-config --includes` -fPIC -c some_script.cpp
but when I run this command I received an error:
g++: error: `php-config: No such file or directory
g++: error: unrecognized option '--includes`'
where can I get php-config shell script without recompiling PHP (under Windows)
The problem is not that you don't have the script, it's that the Windows shell doesn't know what you're trying to do because it doesn't support backticks. The command wants to run the php-config script and include the output in the command, but instead g++ is being passed \php-configas the first argument, and--includes`` as the second argument, which are not valid arguments to GCC.
You can't run a UNIX shell command in Windows. Either use a UNIX-style shell (e.g. via Cygwin or Mingw32) or just use a different command, e.g. figure out what the necessary include flags are and use them:
g++ -I/some/path -fPIC -c some_script.cpp

Having problems while try to install OAUTH with PECL in MAMP on mac OS lion

i am new to setting php servers, and i had go though other related post, seems like nobody have the same error as i have.
I am using MAMP 2.0.2, and running PHP 5.3.6,
and I was trying to install oAuth on my local MAMP, using following commands:
$ cd /Applications/MAMP/bin/php/php5.3.6/bin
$ ./pecl install oauth
however, it return such error:
Notice: unserialize(): Error at offset 276 of 1133 bytes in Config.php on line 1050
ERROR: The default config file is not a valid config file or is corrupted.
What is happening? PECL is bundled in MAMP, which should be working out of the box....
Update:
I read a post elsewhere suggest that the config file's data, which holds the install paths are in-correct, so i changed some value in the following file :
/Applications/MAMP/bin/php/php5.3.6/conf/pear.conf
Then, i use the command:
$ ./pecl install oauth
Which it starts download and unpack, but when it try to install, it gives:
creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
running: make
/bin/sh /private/tmp/pear/temp/pear-build-user1RU5EZA/oauth-1.2.2/libtool --mode=compile cc -I. -I/private/tmp/pear/temp/oauth -DPHP_ATOM_INC -I/private/tmp/pear/temp/pear-build-user1RU5EZA/oauth-1.2.2/include -I/private/tmp/pear/temp/pear-build-user1RU5EZA/oauth-1.2.2/main -I/private/tmp/pear/temp/oauth -I/Applications/MAMP/bin/php/php5.3.6/include/php -I/Applications/MAMP/bin/php/php5.3.6/include/php/main -I/Applications/MAMP/bin/php/php5.3.6/include/php/TSRM -I/Applications/MAMP/bin/php/php5.3.6/include/php/Zend -I/Applications/MAMP/bin/php/php5.3.6/include/php/ext -I/Applications/MAMP/bin/php/php5.3.6/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -Wall -g -c /private/tmp/pear/temp/oauth/oauth.c -o oauth.lo
mkdir .libs
cc -I. -I/private/tmp/pear/temp/oauth -DPHP_ATOM_INC -I/private/tmp/pear/temp/pear-build-user1RU5EZA/oauth-1.2.2/include -I/private/tmp/pear/temp/pear-build-user1RU5EZA/oauth-1.2.2/main -I/private/tmp/pear/temp/oauth -I/Applications/MAMP/bin/php/php5.3.6/include/php -I/Applications/MAMP/bin/php/php5.3.6/include/php/main -I/Applications/MAMP/bin/php/php5.3.6/include/php/TSRM -I/Applications/MAMP/bin/php/php5.3.6/include/php/Zend -I/Applications/MAMP/bin/php/php5.3.6/include/php/ext -I/Applications/MAMP/bin/php/php5.3.6/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -Wall -g -c /private/tmp/pear/temp/oauth/oauth.c -fno-common -DPIC -o .libs/oauth.o
In file included from /private/tmp/pear/temp/oauth/oauth.c:14:
/private/tmp/pear/temp/oauth/php_oauth.h:20:10:
fatal error: 'php.h' file not found
include "php.h"
^
1 error generated.
make: *** [oauth.lo] Error 1
ERROR: `make' failed
Again, what is happening?
I know this is old but I found this question while having a similar issue.
MAMP doesn’t ship with a bunch of the PHP sources
Download MAMP components and configure
URL: http://www.mamp.info/en/downloads/index.html (i.e. MAMP_components_2.0.2.zip)
Unpack your MAMP_components_2.0.2.zip
Identify your php-5.x.x.tar.gz file (where 5.x.x is your version of PHP)
If you are using php > 5.4.10 then download the sources from http://php.net/releases as they are not in the MAMP components download (credit pulkitsinghal in comments)
Create directory for your PHP sources:
mkdir -vp /Applications/MAMP/bin/php5/include
Untar php-5.x.x.tar.gz into /Applications/MAMP/bin/php/php5.*/include or /Applications/MAMP/bin/php5/ include:
tar zxvf php-5.x.x.tar.gz -C /Applications/MAMP/bin/php/php5.?.??/include
Rename your php-5.x.x directory to php (without the version numbering):
mv /Applications/MAMP/bin/php/php5.2.17/include/php-5.?.?? /Applications/
MAMP/bin/php/php5.2.17/include/php
Configure PHP sources (it’ll create necessary files i.e. zend_config.h, tsrm_config.h, etc.):
cd /Applications/MAMP/bin/php/php5.?.??/include/php
./configure
The process was for another fix but this resolved the issues with php.h not being found
Credit to where I found the answers - :
Thomas Hunter Blog
Google Doc detailing process
I had the same problem whilst trying to pecl install -f ssh2 with MAMP.
Here's how I fixed it:
MAMP doesn't provide the source code archive for PHP 5.4.10 so download it from php.net
Extract the source code archive to /Applications/MAMP/bin/php/php5.4.10/include/php
Run ./configure to configure the source code for your platform (without this step the pecl install will fail looking for a bunch of header files)
Retry your pecl install
(much thanks to Stephen's answer which is pretty much the same)
This is a complement to Stephen's answer and Greg's comment
When compiling xdebug 2.3.2 for php 5.6.2 on OSX 10.10.2, I could not get rid of the
'zend_config.h' file not found
error until I added the following option to ./configure in the php folder:
./configure --without-iconv
Credits to Cameron Browning
PECL Modules are compiled modules, in order to install them, you need the PHP headers. You can found the headers on php.net/downloads.php make sure you download a version which match with your PHP version. Then you can follow this : Installing PHP OAuth in MAMP environment

Any docs about V8JS in PHP?

Is there any documentation about V8JS?
Do I need only standard PHP or some extensions to use V8JS?
I'll be very thankful for any information about V8JS in PHP.
Requirements
PHP 5.3.3+ and V8 library and headers installed in proper paths.
Install
I've found this docs on the v8js class.
The docs out there aren't complete or are not updated. I'm actually currently in the process of doing v8JS myself and it took me a few days to get the back end libs sorted out. First off, you must know that you can't do this is you have python < 2.7
Here is my install notes that I'm putting together for our dev vagrant boxes running centos 7.
cd /tmp
# Install depot_tools first (needed for source checkout)
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH=`pwd`/depot_tools:"$PATH"
# Download v8
fetch v8
cd v8
# Build (disable snapshots for V8 > 4.4.9.1)
make native library=shared snapshot=off -j8
# Install to /usr
sudo mkdir -p /usr/lib /usr/include
sudo cp out/native/lib.target/lib*.so /usr/lib64/
sudo cp -R include/* /usr/include
echo -e "create /usr/lib64/libv8_libplatform.a\naddlib out/native/obj.target/tools/gyp/libv8_libplatform.a\nsave\nend" | sudo ar -M
cd /usr/lib64
sudo chrpath -r '$ORIGIN' libv8.so
========================
Compile php-v8js itself
========================
cd /tmp
git clone -b master https://github.com/phpv8/v8js.git
cd v8js
phpize
./configure
make
make test
sudo make install
sudo service httpd restart
A note on the line make native library=shared snapshot=off -j8. I had the compile stop on me a couple times, I just restarted it. I'm not sure why it stopped, but it restarted just fine and completed just fine.
After that is done, you need to create the php extension file /etc/php.d/v8js.ini with the following content
; Enable v8js extension module
extension=v8js.so
Run the following to make sure it is installed correctly
php -r "phpinfo();" | grep v8js
If you get output back and no errors you're good to go.

Categories