Ubuntu下uwsgi启动django实战(python虚拟环境)

本文详细介绍了在Ubuntu系统中,如何在Python虚拟环境中使用uwsgi部署Django项目,并通过nginx进行代理配置。内容包括uwsgi的基本安装、Django项目的创建、uwsgi启动命令与配置文件的使用,以及nginx的配置和测试。
摘要由CSDN通过智能技术生成

1.Uwsgi基本安装配置

   1).环境描述

      系统环境:ubuntu

      Python环境:python2.7

   2).django及uwsgi安装

  1. pip install django
  2. pip install uwsgi

   3).测试uwsgi

        编辑vi /home/test.py

# test.py

def application(env, start_response):

    start_response('200 OK', [('Content-Type','text/html')])

    #return [b"Hello World"] # python3

    return ["Hello World"] # python2

       启动命令uwsgi --http-socket :9000 --plugin python --wsgi-file test.py

       使用浏览器访问测试:http://127.0.0.1:9000/

       

     4).一些启动命令的报错及原因:

       使用uwsgi --http 127.0.0.1:9000 --wsgi-file test.py命令启动时,报错:

       uwsgi: option '--http' is ambiguous;

       

       问题根源是没有这个uwsgi插件应该使用 --http-socket  参数

       使用命令:uwsgi --http-socket 127.0.0.1:9000 --wsgi-file test.py启动时报:

       uwsgi: unrecognized option '--wsgi-file'

       getopt_long() error

       

       问题原因:uwsgi不识别后面的wsgi  python文件,无法解析

       解决方式:在--wsgi-file 参数前加上--plugin python 参数,

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值