skip to Main Content

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?

4

Answers


  1. The easiest option I found was to build it myself. Tested on Amazon Linux release 2 (Karoo).

    1. 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 -

    2. Go into the created directory and create the Makefile with our system dependant options:
      cd ./sqlite-autoconf-3320300 && ./configure

    3. Build the binary
      make

    4. Install it
      sudo make install

    5. 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.

    Login or Signup to reply.
  2. Adding on to @halbgut answer, with some changes:

    1. 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 -

    2. Go into the created directory and create the Makefile with our system dependent options:
      cd ./sqlite-autoconf-3320300 && ./configure

    3. Build the binary
      make

    4. 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
    
    Login or Signup to reply.
  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.

    Login or Signup to reply.
  4. 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.

    enter image description here

    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 
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search