Centos系统部署python django程序过程记录

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/lu_yongchao/article/details/71598408

Centos系统部署python django程序过程记录。

python2.7+apache2.4+mod_wsgi

之前学习的时候配置成功过,但是这种方式与python及apache捆绑严重,不推荐;

使用Gunicorn+Nginx部署

是UNIX的纯Python WSGI服务器。它没有依赖关系,易于安装和使用。
Django官网的Gunicorn部署方式介绍

使用uwsgi+Nginx部署

网友分享的uWSGI详解

安装一些基础组件

先后执行如下两条命令安装一些基础组件

yum groupinstall "Development tools"

yum install zlib-devel bzip2-devel pcre-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel

安装uwsgi

安装命令:python3 -m pip install uwsgi

默认安装后在/usr/bin/不会创建uwsgi命令的快捷方式,手工创建方法如下:ln -s /usr/local/python3/bin/uwsgi /usr/bin/uwsgi

测试uwsgi的安装

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

def application(env, start_response):
    start_response('200 OK', [('Content-Type','text/html')])
    return [b"Hello World"]

通过uwsgi运行该文件。uwsgi --http :8001 --wsgi-file test.py

这里写图片描述

使用python验证django为ok状态

首先得保证我们的Django项目没有问题,通过python命令发布 django web程序,命令如下:

python3 manage.py runserver 0.0.0.0:8001  

访问http://localhost:8001,项目运行正常,说明我们准备的django web程序为ok状态。

本次的这个学习课题对自己来说存在的困难,先记录到这里,这篇文章一定要监督自己写完,目标本月25号以前。

扫描二维码关注公众号,回复: 3859914 查看本文章

网友分享的关于部署python web程序的总结:

1、全面解读python web 程序的9种部署方式

2、Django Nginx+uwsgi 安装配置

3、通过Nginx部署Django(基于ubuntu)

4、Ubuntu上通过nginx部署Django笔记

猜你喜欢

转载自blog.csdn.net/lu_yongchao/article/details/71598408