django项目部署

进入虚拟环境:
pip install django==3.2.5 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip install uwsgi -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

pip install djangorestframework -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip install djangorestframework-jwt -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip install pymysql  -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

pip install django-cors-headers -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

cd /djpro1/p1/mydrf
django-admin startproject mydfr
cd /django/p1/mydfr
python manage.py startapp app01

Python uWSGI 安装配置
https://www.runoob.com/python3/python-uwsgi.html
https://www.cnblogs.com/jinggege-0224/p/12607484.html
https://www.cnblogs.com/jinggege-0224/p/12607484.html

https://blog.csdn.net/cz9025/article/details/86681428
测试uwsgi,报错Unhandled object from iterator

wuyepiaoxue789 2021-01-05 16:06:30 301 收藏 1
分类专栏: Python
版权

Python
专栏收录该内容
28 篇文章0 订阅
订阅专栏
pip install uwsgi
uwsgi --version # 查看 uwsgi 版本
测试 uwsgi 是否正常:

新建 test.py 文件,内容如下:

def application(env, start_response):
start_response('200 OK', [('Content-Type','text/html')])
return "Hello World"
然后在终端运行:

uwsgi --http :8001 --wsgi-file test.py
在浏览器内输入:http://127.0.0.1:8001,查看是否有"Hello World"输出

访问地址,后台报错:

解决:对于python3则应当注意要指明编码,否则uwsgi不会发送网页内容

​def application(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/html')])
test = 'hello world'

————————————————
版权声明:本文为CSDN博主「wuyepiaoxue789」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/wuyepiaoxue789/article/details/112240544

uWSGI的安装及配置详解
https://blog.csdn.net/weixin_42134789/article/details/115713572

编译 安装nginx
https://blog.csdn.net/yuanfangPOET/article/details/90045001
nginx-1.13.7.tar.gz
cd nginx-1.13.7
./configure --prefix=/opt/report/nginx

https://www.cnblogs.com/renoyuan/p/11750756.html

1.日常数据库表结构变更、数据查询
2.从监控中寻找待优化SQL
3.每周进行后台select * 语句统计
4.数据库相关文档整理

Django 3.2.5
Python 3.7.9
asgiref 3.4.1
Django 3.2.5
django-cors-headers 3.7.0
djangorestframework 3.12.4
djangorestframework-jwt 1.11.0
pip 21.1.3
PyJWT 1.7.1
PyMySQL 1.0.2
pytz 2021.1
setuptools 57.4.0
sqlparse 0.4.1
typing-extensions 3.10.0.0

virtualenv env379 --python=python3.7.9
cd env379/bin

pip install django==3.2.5 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

pip install django-cors-headers3.7.0 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip install djangorestframework
3.12.4 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip install djangorestframework-jwt==1.11.0 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

source /opt/report/env368/bin/activate

vim /opt/report/monitor_report/monitor_report/settings.py

(env368) [root@dbasvr report]# cd monitor_report/
(env368) [root@dbasvr monitor_report]# python manage.py runserver 172.16.20.227:8000

cd /opt/report/monitor_report/monitor_report

/opt/report/nginx/sbin/nginx -s reload

启动uwsgi
uwsgi --ini /opt/report/monitor_report/monitor_report/uwsgi.ini
ps -ef|grep uwsgi

[uwsgi]

http=:8888

配置和nginx连接的socket连接

socket=127.0.0.1:8997

配置项目路径,项目的所在目录

chdir=/djpro1/p1/mydrf/

配置wsgi接口模块文件路径,也就是wsgi.py这个文件所在的目录名

wsgi-file=mydrf/wsgi.py

配置启动的进程数

processes=4

配置每个进程的线程数

threads=2

配置启动管理主进程

master=True

配置存放主进程的进程号文件

pidfile=/tmp/uwsgi.pid

配置dump日志记录

daemonize=/tmp/uwsgi.log

https://www.cnblogs.com/renoyuan/p/11750756.html

原文地址:https://www.cnblogs.com/skyan/p/15023452.html