使用gunicorn部署django项目的问题
作者:搬砖的Fish 时间:2022-07-16 16:39:55
1、开发环境运行项目
python mange.py runserver 0.0.0.0:8000
2、使用gunicorn在生产环境部署
Gunicorn“绿色独角兽”是一个被广泛使用的高性能的Python WSGI UNIX HTTP服务器
pip install gunicorn
gunicorn -w 2 -b 0.0.0.0:8000 project_django.wsgi
常用参数:
-c 指定一个配置文件(py文件)
-b 与指定的socket进行绑定
-D 以守护进程形式来运行Gunicorn进程,其实就是将这个服务放到后台去运行
-w 工作的进程数量;
-k 工作进程类型,sync(默认), eventlet, gevent, or tornado, gthread, gaiohttp.
http://docs.gunicorn.org/en/latest/settings.html
3、其它:使用gunicorn部署django项目时,发现静态文件加载失败问题
在项目project_django/urls.py中更改如下即可搞定:
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns = [
url('^admin/', admin.site.urls),
]
urlpatterns += staticfiles_urlpatterns()
来源:https://blog.csdn.net/Disany/article/details/111846266
标签:gunicorn,部署,django
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Google的设计导引
2008-04-06 14:18:00
python实现图像拼接功能
2021-05-21 12:44:19
![](https://img.aspxhome.com/file/2023/0/80440_0s.jpg)
Python sublime安装及配置过程详解
2021-07-06 19:57:47
![](https://img.aspxhome.com/file/2023/6/67736_0s.png)
Python OpenCV基于霍夫圈变换算法检测图像中的圆形
2023-11-12 05:33:36
![](https://img.aspxhome.com/file/2023/8/64238_0s.jpg)
跟老齐学Python之有点简约的元组
2022-04-11 10:21:43
python中dict()的高级用法实现
2022-06-16 23:24:29
![](https://img.aspxhome.com/file/2023/2/84122_0s.png)
详解python--模拟轮盘抽奖游戏
2023-07-25 15:35:14
![](https://img.aspxhome.com/file/2023/5/71395_0s.png)
django从请求到响应的过程深入讲解
2021-08-09 19:41:06
![](https://img.aspxhome.com/file/2023/8/72868_0s.png)
纯CSS在Firefox模拟text-overflow: ellipsis效果
2009-03-17 12:49:00
![](https://img.aspxhome.com/file/UploadPic/20093/17/firefox-css-text-overflow-21s.gif)
Django 通过JS实现ajax过程详解
2023-08-17 08:00:46
golang映射Map的方法步骤
2023-08-28 09:10:22
python 爬虫爬取京东ps4售卖情况
2022-05-19 01:35:28
![](https://img.aspxhome.com/file/2023/5/72255_0s.png)
磁盘缓存专题之一 缓存命中和缓存未命中&缓存与缓冲间的差异
2012-10-07 11:02:46
Asp.net实现简单的文字水印
2007-08-24 09:28:00
如何用拦截表单的方法上传图片?
2010-06-16 09:50:00
用ASP实现就MP3曲目信息的操作全攻略
2008-05-28 12:42:00
说说CSS Hack 和向后兼容
2010-05-17 13:11:00
![](https://img.aspxhome.com/file/UploadPic/20105/17/css-hack-and-standard-31s.png)
python爬虫 urllib模块反爬虫机制UA详解
2022-04-07 02:22:51
![](https://img.aspxhome.com/file/2023/9/70209_0s.png)
CSS.JS文件发布机制的思考
2009-08-04 13:07:00
Python基于socket实现TCP客户端和服务端
2023-09-29 15:30:05