将一个使用Django框架的网站部署到阿里云服务器。
服务器是centOS系统,大三的时候学过linux,考完试后就没怎么接触了,这次部署网站需要用到大量的linux命令,好在以前基础还行,先在网上找点资料,复习下linux命令,就开始实操了。
1.1安装sqlite-devel
防止出现:ModuleNotFoundError: No module named '_sqlite3'错误
命令:
# yum -y install sqlite-devel
1.2安装编译工具及库文件
# yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
1.3下载python3.6
# wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tgz
将Python3安装在/usr/local/python3
# mkdir /usr/local/python3
# tar -zxvf Python-3.6.2.tgz
# cd Python-3.6.2
# ./configure --prefix=/usr/local/python3
# make
# make install
建立Python的软链
# ln -s /usr/local/python3/bin/python3 /usr/bin/python3
将/usr/local/python3/bin加入PATH
# vim ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:/usr/local/python3/bin
export PATH
按ESC,输入:wq回车退出。
修改完记得执行下面的命令,让上一步的修改生效:
# source ~/.bash_profile
检查是否设置成功:
1.4安装虚拟环境
pip3 install virtualenv
在 /usr/local/envs下创建虚拟环境
# virtualenv env_test
启用虚拟环境
# cd env_test
# source bin/activate