云服务器环境:CentOS 7.6

python环境:python3.7.2

sqlite3:3.36.0

django:3.2.3

第一步:系统环境配置

1.1 安装依赖

yum -y update
yum -y install python-devel zlib-devel mysql-devel libffi-devel bzip2-devel openssl-devel java wget gcc

1.2  安装git redis nginx supervisor

yum -y install git redis nginx supervisor

1.3 设置开机自启动

systemctl enable redis nginx supervisord

 

第二步:python3 安装

安装相关依赖
yum -y groupinstall "Development tools"

yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel

下载不同版本的Python3,我下载的是Python3.7.2, 可以在浏览器下载好后再上传

下载
wget https://www.python.org/frp/python/3.7.2/Python-3.7.2.tgz

创建目录
mkdir /usr/local/python3 
tar -xvf  Python-3.7.2.tgz
cd Python-3.7.2
./configure --prefix=/usr/local/python3 --enable-optimizations
make && make install

创建软链接
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

验证python
python3 -V
pip -V

第三步:数据库相关配置

下载安装sqlite3 版本(django中会冲突,不更新的话)

sqlite3 --version
wget  https://www.sqlite.org/2019/sqlite-autoconf-3290000.tar.gz
tar -xaf sqlite-autoconf-3290000.tar.gz
cd sqlite-autoconf-3290000/
./configure --prefix=/usr/local/
make && make install
mv  /usr/bin/sqlite3 /usr/bin/sqlite3.bak
ln -s /usr/local/bin/sqlite3 /usr/bin/sqlite3
echo export LD_LIBRARY_PATH="/usr/local/lib">> ~/.bashrc
source ~/.bashrc
sqlite3 --version

MySQL数据库安装及配置

 

第四步:安装Elasticsearch

Elasticsearch是一个基于Lucene的搜索服务器。它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口

 

第五步:发布项目

5.1 移植代码

5.2 安装包(requirements.txt 汇总所有第三方包)

sudo pip3 install -r requirements.txt