Step 0:Install A,B,C,blabla needed

This can be seen in my another article in the blog.click here(unavailable now,just in the future)

Step 1:Create A Django Project

chdir /path/to/your/project/base/

django-admin.py startproject mysite

Step 2:Create Your uwsgi congfigure files and Edit them

chdir /path/to/your/project/base/mysite

touch mysite_uwsgi.conf mysite_uwsgi.py mysite_uwsgi.ini mysite_mysite_uwsgi.pid uwsgi.pid

sudo ln -s /path/to/your/project/base/mysite/mysite_uwsgi.conf /etc/nginx/sites-enabled/ # so that this configuration can be included into nginx's conf

# sudo ln -s /path/to/your/project/base/mysite/mysite_uwsgi.conf /etc/nginx/sites-enabled/mysite_nginx.conf # another name is also ok!

## ------------------------------------------------------------------------------------------------------------------------

vim mysite_uwsgi.conf

# mysite_uwsgi.conf
server {
listen 8000;
server_name 10.10.10.132; # after all of these steps,type http://10.10.10.132:8000/ into your browser to get what you want(ps.10.10.10.132 is my IP)
charset UTF-8; client_max_body_size 75M; location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:8001; # nginx(not you) wiil get something from 127.0.0.1:8001 then return to you
uwsgi_read_timeout 2;
}
location /static {
expires 30d;
autoindex on;
add_header Cache-Control private;
alias /path/to/your/project/base/mysite/mysite/static/;
}
}

  

# ln this file into the '/path/to/nginx/site-enable/' (have done in step 2 'sudo ln blablablabla')

## ------------------------------------------------------------------------------------------------------------------------

vim mysite_uwsgi.py

# mysite_uwsgi.py
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

  

## ------------------------------------------------------------------------------------------------------------------------

vim mysite_uwsgi.ini

[uwsgi]
socket = :8001
master = true
module = mysite_uwsgi
processes = 8
listen = 120
enable-threads = true
daemonize = /path/to/your/project/base/mysite/mysite_uwsgi.log
pidfile = /path/to/your/project/base/mysite/mysite_uwsgi.pid
pythonpath = /path/to/your/project/base/mysite/
pythonpath = /path/to/your/project/base/mysite/mysite_uwsgi
pythonpath = /path/to/your/project/base/mysite/mysite
buffer-size = 32768
reload-mercy = 8
vacuum = true

After all of these above,we can go to Step 3.

Step 3:Restart Your Nginx Service And uWsgi service

Here list the Commonly used commands:
sudo /etc/init.d/nginx stop

sudo /etc/init.d/nginx start

sudo /etc/init.d/nginx restart

And in this step you just need to restart your nginx(if it is started before, or use start instead)

sudo /etc/init.d/nginx restart # restart nginx

chdir /path/to/your/project/base/mysite

uwsgi --socket 127.0.0.1:8001 --wsgi-file mysite_uwsgi.py # start uwsig service,if not,you will get a 502(Bad Gateway) error.

Tips:

  chdir /path/to/your/project/base/mysite

  uwsgi --http 10.10.10.132:8001 --wsgi-file mysite_uwsgi.py

  and then type http://10.10.10.132:8000/ in your browser to see if uwsgi work ok.if ok ,then shose socket

Tips:

  nginx + uwsgi

  apache + mod_wsgi

  nginx + apache + ???

 Step 4:Check If It is OK

Open your browser and type http://10.10.10.132:8000/ (10.10.10.132:8000 also ok)

And you will see the django's beautiful welcome page.

Q1:invalid request block size: 21573 (max 4096)...skip

uwsgi --socket :8052 --wsgi-file demo_wsgi.py --protocol=http

http://stackoverflow.com/questions/15878176/uwsgi-invalid-request-block-size

Q2:The requested URL /public was not found on this server.

 # Django media
location /media {
alias /path/to/your/mysite/media; # your Django project's media files - amend as required
} location /static {
alias /path/to/your/mysite/static; # your Django project's static files - amend as required
} # Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass django;
include /path/to/your/mysite/uwsgi_params; # the uwsgi_params file you installed
}

for more information:

tutorial from uwsgi.readthedocs.org:Django_and_nginx (follow it but failed,orz...)

tutorial from oschina.net:nginx + uwsgi + django (work)

Start Your Django Project in Nginx with uWsgi的更多相关文章

  1. 基于Nginx 和 uwsgi 搭建 django.

    第一篇博客,不是很懂语法之类的,希望通过多写点东西,记录自己的成长,早点成为一个pyer. 就写下这两天折腾的这个nginx-uwsgi-django. 首先附上官方文档链接 http://uwsgi ...

  2. centos 7下 django 1.11 + nginx 1.12 + uwsgi 2.0

    之前写过一个博客关于如何安装django的,见下网址, http://www.cnblogs.com/qinhan/p/8732626.html 还有一个网址如何安装nginx的 http://www ...

  3. 安装Django、Nginx和uWSGI

    安装Django.Nginx和uWSGI 1.确定已经安装了2.7版本的Python: 2.安装python-devel yum install python-devel 3.安装uwsgi pip ...

  4. 基于Nginx和uWSGI在Ubuntu上部署Django项目

    前言: 对于做Django web项目的童鞋,重要性不言而喻. 参考:https://www.cnblogs.com/alwaysInMe/p/9096565.html https://blog.cs ...

  5. Nginx+Python+uwsgi+Django的web开发环境安装及配置

    Nginx+Python+uwsgi+Django的web开发环境安装及配置 nginx安装 nginx的安装这里就略过了... python安装 通常系统已经自带了,这里也略过 uwsgi安装 官网 ...

  6. centos6.5安装nginx+python+uwsgi+django

    nginx+uwsgi+django环境部署及测试 默认系统自带的python2.6.6 第一步(安装setuptools) wget https://pypi.python.org/packages ...

  7. nginx 基于uwsgi部署Django

    1.安装nginx yum install -y nginx(需要epel源) 2.安装环境 可以考虑使用虚拟化环境,本处不再使用 3.安装uwsgi yum groupinstall "D ...

  8. 项目的发布(nginx、uwsgi、django、virtualenv、supervisor)

    导论 WSGI是Web服务器网关接口.它是一个规范,描述了Web服务器如何与Web应用程序通信,以及Web应用程序如何链接在一起以处理一个请求,(接收请求,处理请求,响应请求) 基于wsgi运行的框架 ...

  9. docker 部署django项目(nginx + uwsgi +mysql)

    最近在学习用docker部署Django项目,经过百折不挠的鼓捣,终于将项目部署成功,爬过好多坑,也发现很多技能需要提高.特此写下随笔与小伙伴们分享,希望能对大家有所启发. docker的理论我就不赘 ...

随机推荐

  1. Hibernate学习之对象持久化

    1.  对象持久化 对象的持久化就是把内存中对象形式的业务数据,转换成数据库中的关系数据形式的业务数据.广义理解,对象的持久化还包括内存与关系数据库之交换业务数据的各种操作. 2. 对象持久化模式 1 ...

  2. 使用gulp在开发过程中合理导出zip文件

    最近一段时间一直在做桌面混合应用,跟以往做web端不同的是,无法再通过在浏览器上输入内部的域名来随时跟踪开发版本的状况了,只能通过打包代码让产品或领导随时跟踪进度. 这里就涉及到一些问题了: 1,需要 ...

  3. 关于怎么将Quartus和Nios程序一起固化到FPGA里面

    系统:win8.1 SDK:Quartus II 14.1 FPGA:Cyclone IV 1.将Quartus生成的.pof文件(配置Flash即可自动生成,这里不讨论),与Nios生成的.elf文 ...

  4. [转] 再叙TIME_WAIT

    http://huoding.com/2013/12/31/316 之所以起这样一个题目是因为很久以前我曾经写过一篇介绍TIME_WAIT的文章,不过当时基本属于浅尝辄止,并没深入说明问题的来龙去脉, ...

  5. ckeditor 敏感词标记显示处理方法

    直接在原型添加方法: (function () { /* * 取消所有高亮 */ CKEDITOR.editor.prototype.CancleSensitiveWordsHighlight = f ...

  6. java InputStream

    java InputStream 当为网络数据流是,不能以read为-1作为数据结束的尾. 而用下列案例获取数据. Log.v(TAG, "==========start========== ...

  7. Sql2008中使用DataTable作为存储过程的参数

    使用DataTable作为存储过程的参数   最近工作中写了几个存储过 程,需要向存储过程中传递字符串,因为SQL Server 2000中没有内置类似于 split 的函数,只好自己处理,将前台数据 ...

  8. Xcode断点的一些黑魔法

    转自 只会左键断点?是时候试试这样那样断点了 编码不能没调试,调试不能没断点(Break Point).XCode的断点功能也是越来越强大. 基本断点 如下图,这种是最常用的断点,也是最容易设置.左键 ...

  9. Java线程(学习整理)--3--简单的死锁例子

    1.线程死锁的概念: 简单地理解下吧! 我们都知道,线程在执行的过程中是占着CPU的资源的,当多个线程都需要一个被锁住的条件才能结束的时候,死锁就产生了! 还有一个经典的死锁现象: 经典的“哲学家就餐 ...

  10. Linux抓包工具tcpdump详解

    tcpdump是一个用于截取网络分组,并输出分组内容的工具,简单说就是数据包抓包工具.tcpdump凭借强大的功能和灵活的截取策略,使其成为Linux系统下用于网络分析和问题排查的首选工具. tcpd ...