PHP compiler supports SQLite3 encryption extension

Since PHP 5.3.0 onwards SQLite3 extension is enabled by default, but due to the open source SQLite 3 version without encryption, if you want to use encryption need to use his commercial version. This results in the default PHP SQLite extension itself does not support encryption, reserved only for the relevant interfaces, see the official document describes:

An optional encryption key used when encrypting and decrypting an
SQLite database. If the SQLite encryption module is not installed,
this parameter will have no effect.

But if the project need to use SQLite, if not encrypted, more or less have little effect on safety. Fortunately, SQLite itself has reserved encryption interface, this interface based on a number of enthusiasts to achieve encryption.

Currently more well-known, respectively, are: wxsqlite3 and sqlcipher, which sqlcipher official has documentation describes how to implement encryption SQLite3 extension php, but wxsqlite3 not, but at the moment well-known database management tool Navicat using wxsqlite3 the library implementation SQLite3 encrypted connection, Therefore, in order to facilitate ongoing maintenance, so plan to use wxsqlite3.

Extension compiler tutorial
First you need to make sure you do not join the SQLite3 extension php main program (using --without-sqlite3 SQLite3 extension is disabled at compile time), if an incident joined, I currently do not know what a good way, feel recompile Enough.

Php official website to download the corresponding source code versions of php (php-7.0.17 In this paper, for example).

Download the source package into the root directory, and unzip

tar -zxf php-7.0.17.tar.gz

SQLite3 extension into the source directory

cd php-7.0.17/ext/sqlite3

All files in the source code wxsqlite3 sqlite3secure / src is copied into /root/php-7.0.17/ext/sqlite3/libsqlite to generate and edit the configuration file precompiled

cp config0.m4 config.m4
vi config.m4

The config.m4 Lane sqlite3_extra_sources = "libsqlite / sqlite3.c" replace sqlite3_extra_sources = "libsqlite / sqlite3secure.c" file generated precompiled

phpize

Precompiled

./configure CFLAGS="-DSQLITE_HAS_CODEC"

Compile and install

make && make install

Finally loaded in php.ini file can be compiled so, then the php to support encrypted version of SQLite3 friends, Mody Mody clatter.

Published 65 original articles · won praise 88 · views 280 000 +

Guess you like

Origin blog.csdn.net/uisoul/article/details/102862563