How to Install SQLite 3.7.5+ on CentOS 6.7: A Step-by-Step Guide


4 views

When working with CentOS 6.7, you might encounter limitations with the default SQLite version (3.6.20) available through yum. Many modern applications require SQLite 3.7.5 or later for features like WAL mode or improved concurrency.

$ yum install sqlite
Package sqlite-3.6.20-1.el6_7.2.x86_64 already installed and latest version
Nothing to do

The most reliable way to get a newer SQLite version is to compile it from source. Here's how:

# Install dependencies
sudo yum groupinstall "Development Tools"
sudo yum install wget

# Download and extract latest SQLite
wget https://www.sqlite.org/2023/sqlite-autoconf-3420000.tar.gz
tar xvfz sqlite-autoconf-3420000.tar.gz
cd sqlite-autoconf-3420000

# Configure and install
./configure --prefix=/usr/local
make
sudo make install

# Update library paths
echo '/usr/local/lib' | sudo tee /etc/ld.so.conf.d/sqlite.conf
sudo ldconfig

After installation, verify the new version is being used:

$ sqlite3 --version
3.42.0 2023-05-16 12:36:15 873ed2b6305f7a79a5a1234f06f239a123a8f66ff0b839d20b57f6df16c6635d

To ensure your system uses the new version:

# Update PATH
echo 'export PATH=/usr/local/bin:$PATH' >> ~/.bashrc
source ~/.bashrc

# Check which sqlite3 is being used
which sqlite3

If you encounter library conflicts:

# For Python applications, you might need to:
sudo yum install sqlite-devel
pip install pysqlite3 --upgrade

For system-wide compatibility, consider creating symbolic links:

sudo ln -sf /usr/local/bin/sqlite3 /usr/bin/sqlite3

CentOS 6.7's default repositories contain SQLite 3.6.20, which is quite outdated. Running yum install sqlite confirms this limitation:

$ yum install sqlite
Package sqlite-3.6.20-1.el6_7.2.x86_64 already installed and latest version
Nothing to do

The most reliable method is compiling from source. Here's the complete process:

# Install dependencies
yum groupinstall "Development Tools"
yum install wget

# Download and extract latest source
wget https://www.sqlite.org/2023/sqlite-autoconf-3420000.tar.gz
tar xvfz sqlite-autoconf-3420000.tar.gz
cd sqlite-autoconf-3420000

# Compile and install
./configure --prefix=/usr/local
make
make install

# Update library paths
echo '/usr/local/lib' > /etc/ld.so.conf.d/sqlite.conf
ldconfig

# Verify installation
/usr/local/bin/sqlite3 --version

If you prefer package management, try EPEL:

# Install EPEL repo
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm

# Search for available versions
yum --disablerepo="*" --enablerepo="epel" list available sqlite*

After installation, you may need to update symbolic links:

# Backup existing binary
mv /usr/bin/sqlite3 /usr/bin/sqlite3.bak

# Create new symlink
ln -s /usr/local/bin/sqlite3 /usr/bin/sqlite3

# Verify path resolution
which sqlite3

If using Python, rebuild sqlite3 module:

# For Python 2.7
yum install python-devel
cd /usr/local/src/Python-2.7.18/Modules/_sqlite
make
cp *.so /usr/lib64/python2.7/lib-dynload/