This took me too much time to implement, after two hours of searching, I didnt found and documentation of how to compile sqlcipher support of ext/sqlite3 of php.
I also posted this to a gist in my github: https://gist.github.com/durich/bf15c091c6d59b042caa142950eaf252
So I'm posting my recipe to compile sqlcipher support to the ext-sqlite3 of php, any recommendations to refined this process is welcome:
#this is for php 7.4 included in distro, may work in other versions of php 7 #install library apt-get install php7.4-dev build-essential #download and compile sqlcipher cd /usr/local/src/ git clone https://github.com/sqlcipher/sqlcipher #compile cd sqlcipher ./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC" LDFLAGS="-lcrypto" make #download php cd /usr/local/src/ wget https://www.php.net/distributions/php-7.4.9.tar.bz2 #extract files tar -xvjf php-7.4.9.tar.bz2 #enter directory cd php-7.4.9/ext/sqlite3 #run phsize phpize #copy m4 file mv config0.m4 config.m4 #run configure SQLITE_LIBS="/usr/local/src/sqlcipher/.libs/" SQLITE_CFLAGS="-I/usr/local/src/sqlcipher/ -DSQLITE_HAS_CODEC -DSQLITE_TEMP_STORE=2" ./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC" LDFLAGS="-lcrypt -L/usr/local/src/sqlcipher/.libs/" --libdir=/usr/local/src/sqlcipher/.libs/sqlite3.o #run make make #check module file sqlite3.so, if less than 110,000 byes, sqlcipher not included ls -l modules/ -l #another to check strings modules/sqlite3.so | grep sqlcip #include /usr/local/src/sqlcipher/.libs/sqlite3.o in the linking, this step is extra, because I'm noob on configure flags and c++ flags, suggestion are welcome vim sqlite3.lo #change line pic_object='.libs/sqlite3.o' #to pic_object='.libs/sqlite3.o /usr/local/src/sqlcipher/.libs/sqlite3.o' #save file #execute again make #check, if greateher thank 110,000 bytes, it linked ok ls -l modules/ -l #check strings, should be alot of functions strings modules/sqlite3.so | grep cip #copy compiled module tu modules, in php7.4 case the directory is /usr/lib/php/20190902/ cp modules/sqlite3.so /usr/lib/php/20190902/ #crear ini files to load in fpm, apache or cli, my case is cli and fpm echo extension=sqlite3.so > /etc/php/7.4/cli/conf.d/20-sqlite3.ini echo extension=sqlite3.so > /etc/php/7.4/fpm/conf.d/20-sqlite3.ini #test php should giver versions in $version->fetchArray query("PRAGMA cipher_version"); if($version){ var_dump($version->fetchArray()); } else { throw new Exception($db->lastErrorMsg()); } $db->exec("PRAGMA key = '$password';"); $db->exec("PRAGMA cipher_page_size = 1024;"); $db->exec("PRAGMA kdf_iter = 64000;"); $db->exec("PRAGMA cipher_hmac_algorithm = HMAC_SHA1;"); $db->exec("PRAGMA cipher_kdf_algorithm = PBKDF2_HMAC_SHA1;");