zoukankan      html  css  js  c++  java
  • 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!
  • 相关阅读:
    eclipsesvn
    js邮箱和正则表达式
    jsreplace
    JQuery与Json转换
    thinkPHP时间戳格式化
    JS绝对定位到右下角
    chrome快捷键
    js配置示例
    JQuery class选择器
    JS调试技巧
  • 原文地址:https://www.cnblogs.com/roronoa-sqd/p/4932806.html
Copyright © 2011-2022 走看看