升级Centos7中SQLite

问题描述

在阿里云的自带centos上启动Django服务报错:
django.core.exceptions.ImproperlyConfigured: SQLite 3.8.3 or later is required (found 3.7.17).
提示SQLite版本太低需要升级
在升级SQLite后启动Django服务依然报错:
django.db.utils.NotSupportedError: deterministic=True requires SQLite 3.8.3 or higher
或sqlite3.NotSupportedError: deterministic=True requires SQLite 3.8.3 or higher
只有重新编译安装Python

升级SQLite

1.下载SQLite

wget https://www.sqlite.org/2019/sqlite-autoconf-3300000.tar.gz
tar -zxvf sqlite-autoconf-3300000.tar.gz

2.安装SQLite

mkdir /opt/sqlite
cd sqlite-autoconf-3300000
./configure --prefix=/opt/sqlite
make && make install

3.建立软连接

mv /usr/bin/sqlite3  /usr/bin/sqlite3_old
ln -s /opt/sqlite/bin/sqlite3  /usr/bin/sqlite3

4.查看当前全局sqlite3的版本

sqlite3 --version

5.配置系统lib库

echo "/opt/sqlite/lib" > /etc/ld.so.conf.d/sqlite3.conf
ldconfig

6.查看Python中的SQLite版本

python3
import sqlite3
sqlite3.sqlite_version

重新编译Python

1.删除之前安装的Python

rm -rf /opt/python3

2.编译安装

cd /opt/Python3.8.5
LD_RUN_PATH=/opt/sqlite/lib ./configure LDFLAGS="-L/opt/sqlite/lib" CPPFLAGS="-I/opt/sqlite/include"  --prefix=/opt/python3
LD_RUN_PATH=/opt/sqlite/lib make
make && make install

修改Django setting.py

ALLOWED_HOSTS = ['39.105.78.171'] #阿里云服务器公网IP 
LANGUAGE_CODE = 'zh-hans'
TIME_ZONE = 'Asia/Shanghai'
USE_TZ = False
# 在PycharmDjango项目运行设置里Host填0.0.0.0
# 端口号默认8000需要在服务器中打开
# 启动服务后访问39.105.78.171:8000

你可能感兴趣的:(Centos,python,centos,django,linux,sqlite)