centos7:
https://www.jianshu.com/p/81ecfa73795b

centos7部署python3环境

  1. 一、更新系统软件包
  2. yum update -y
  3. 二、 安装软件管理包和可能使用的依赖
  4. yum -y groupinstall "Development tools"
  5. yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel
  6. python3 -V
  7. cd /opt
  8. wget https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tgz
  9. tar -zxvf Python-3.6.6.tgz
  10. # 查看是不是解压是不是好的
  11. cd /opt/Python-3.6.6/bin/
  12. python3
  13. ./configure --prefix=/opt/Python-3.6.6
  14. make
  15. make install
  16. python3 -V
  17. #添加软链接
  18. ln -s /opt/Python-3.6.6/bin/python3 /usr/bin/python3
  19. ln -s /opt/Python-3.6.6/bin/pip3 /usr/bin/pip3
  20. #查看软链接是否添加好
  21. python3 --version
  22. pip -V

centos7部署django

#拉代码
cd /opt
git clone https://github.com/Eden445129997/test-platform-django.git

#安装依赖
cd test-platform-django/
pip3 install -r requirements.txt -i http://pypi.douban.com/simple/
#不行就一个一个安装
pip3 install django==3.0.6
pip3 list

#修改一些django框架本身的问题
vim /opt/Python-3.6.6/lib/python3.6/site-packages/django/db/utils.py

#直接命令行运行查看环境

uwsgi运行django

# 安装uwsgi
pip3 install uwsgi
# 添加软链接
ln -s /opt/Python-3.6.6/bin/uwsgi /usr/bin/uwsgi
# 创建uwsgi.ini文件(配置文件部署)
touch uwsgi.ini
# 编辑uwsgi.ini文件(配置文件在后面)
vi uwsgi.ini

#通过配置文件执行uwsgi运行项目
uwsgi --ini uwsgi.ini

uwsgi.ini配置文件

[uwsgi]
# 项目的路径
chdir = /opt/test-platform-django
# Django的wsgi文件
module = main.wsgi:application
# 进程相关的设置
# 主进程
master = true
# 最大数量的工作进程
processes = 10
# 端口
http = :9998
# 设置socket的权限
chmod-socket = 666
# 退出的时候是否清理环境
vacuum = true
# 最大请求
max-requests = 500
# 表示日志不记录正常日志,只记录错误信息
#disable-logging = true
# 日志路径
daemonize = /opt/test-platform-django/logs/uwsgi.log