Installing the latest SQLite on ubuntu

Recently, I needed to install a more recent version of SQLITE because the one in Ubuntu 22.04 did not support json queries compatible with mysql. Interestingly, could not find updated repository so I compiled from source.

Compiling from source does provide latest binaries but the library was not updated

Compile from code

wget https://sqlite.org/2023/sqlite-autoconf-3430100.tar.gz
tar -xf sqlite-autoconf-3430100.tar.gz 
cd sqlite-autoconf-3430100
./configure
make
make install

At this point you should have working cli binaries in the path but no library

Compiled the shared library

from , I used the following code:

gcc \
-Wl,-soname,libsqlite3.so.0 \
-DSQLITE_DISABLE_DIRSYNC \
-DSQLITE_ENABLE_COLUMN_METADATA \
-DSQLITE_ENABLE_FTS3 \
-DSQLITE_ENABLE_RTREE \
-DSQLITE_ENABLE_JSON1 \
-DSQLITE_ENABLE_UNLOCK_NOTIFY \
-DSQLITE_SECURE_DELETE \
-DSQLITE_TEMP_STORE=1 \
-DSQLITE_DTHREADSAFE=1 \
-shared \
-o libsqlite3.so \
-fPIC \
sqlite3.c

This should generate a libslite3.so for you

copying the library

On ubuntu, the folder where the library is architecture dependent so a wildcard helps

cp libsqlite3.so /tmp
pushd /usr/lib/*-linux-gnu
cp /tmp/libsqlite3.so .
ls *sqlite* 
#this should give you the name of your sqlite lib, back up
mv libsqlite3.so.0.8.6 old.libsqlite3.so.0.8.6
mv libsqlite3.so libsqlite3.so.0.8.6
#restart apache
systemctl restart apache2
php -r 'phpinfo();'|grep SQLite

at this point if all worked, the version should be the one you installed (in my case 3.43)

if not, overrite the new library with the one you backed up

Have fun!