一、安装各种依赖包
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 gcc automake autoconf libtool make wget
二、下载Python 3.7 源码
此处省略可参考上一篇文章https://www.mrzhao.site/2019/04/26/%e6%9c%8d%e5%8a%a1%e5%99%a8%e5%ae%89%e8%a3%85python/
三、升级pip
pip3 install --upgrade pip
四、安装拓展包
yum install epel-release
yum install python-pip
pip install pipenv
yum install nodejs//先安装nodejs,才能使用npm
npm install pm2 -g
五、安装并创建Django项目
pip install django//安装Django
django-admin --version//查看Django版本
django-admin startproject testproject //创建项目
cd testproject
设置SQLite3为默认数据库
python manage.py migrate
创建超级用户
python manage.py createsuperuser
将当前本地IP保存到settings.py中
运行服务器
python manage.py runserver 0.0.0.0:8000
浏览器输入远程VPS的IP地址:8000验证
六、创建脚本文件start.sh
start 应该在manager.py的同级目录下
vi start.sh
i
python manage.py runserver 0.0.0.0:9000
:wq
七、使用pm2运行脚本,启动django服务
pm2 start start.sh
pm2 list//查看服务运行状态
pm2 delete start.sh//停止服务
发表回复