• Ubuntu + Django + Nginx + uwsgi



    环境

      Ubuntu 14.04

      Python 2.7

      Django 1.8.4


    1 安装Nginx

             sudo apt-get install nginx 

      测试   sudo /etc/init.d/nginx start         stop、restart 或者  sudo serivce nginx start /stop/restart 

           默认开启0.0.0.0:80


    2 安装uwsgi

    sudo apt-get install python-dev   #!不安装下面可能会出错
    
    pip install uwsgi

      测试  sudo uwsgi --http :8000 --wsgi-file test.py 

    test.py


    def application(env, start_response):
      start_response = ("200 OK", [('Content-Type', 'text/html')])
      return "Hello UWSGI!"  #python2

      #return [b"Hello World"] # python3

    3 基于Nginx和uwsgi部署Django

      原理   the web client <-> the web server(nginx) <-> the socket <-> uwsgi <-> Django 

         

      若第2步能成功,说明 the web client <-> uWSGI <-> Python 是畅通的

      确认Django的project本身没问题  python manage.py runserver 0.0.0.0:8000 

      使用uwsgi把project拉起来  uwsgi --http :8000 --module mysite.wsgi 

        

      

    KEEP LEARNING!
  • 相关阅读:
    装箱与拆箱,数组 糖不苦
    产生乱码的原因 糖不苦
    jQuery 库中的 $() 是什么? 糖不苦
    什么是jQuery 糖不苦
    ATM管理系统 糖不苦
    JS事件委托中同一个标签执行不同操作
    js实现36进制
    js+php+mysql实现的学生成绩管理系统
    两数之和
    函数防抖
  • 原文地址:https://www.cnblogs.com/roronoa-sqd/p/4932806.html
Copyright © 2020-2023  润新知