本文基于root用户安装配置,实现django项目名为trcode

sudo apt-get update
sudo apt-get install python-pip
sudo apt-get install python2.7-dev
sudo python2.7 -m pip install uwsgi
pip install Django==1.9.2
安装剩余环境包
项目根目录创建trcode_uwsgi.ini
# trcode_uwsgi.ini file
[uwsgi]

# Django-related settings

socket = :8000

# the base directory (full path)
chdir           = /home/trcode

# Django s wsgi file
module          = trcode.wsgi

# process-related settings
# master
master          = true

# maximum number of worker processes
processes       = 4

# ... with appropriate permissions - may be needed
# chmod-socket    = 664
# clear environment on exit
vacuum          = true

cd /home/trcode
项目启动uwsgi
uwsgi --ini trcode_uwsgi.ini

安装nginx同时添加nginx-gridfs
1、安装各种依赖包
apt-get install zlib1g-dev
apt-get install libpcre3 libpcre3-dev
apt-get install openssl libssl-dev
2、安装nginx-gridfs
apt-get install git
git clone https://github.com/mdirolf/nginx-gridfs.git
cd nginx-gridfs
git checkout v0.8
git submodule init
git submodule update
cd
3、安装nginx
wget http://nginx.org/download/nginx-1.4.7.tar.gz
tar zxvf nginx-1.4.7.tar.gz
cd nginx-1.4.7
./configure --with-openssl=/usr/include/openssl --add-module=../nginx-gridfs/
#进入主目录 gedit objs/Makefile修改一个小错误,把第3行的-Werror错误去掉,不然会报一个unused错误
make
make install

gedit /usr/local/nginx/conf/nginx.conf文件,http中添加如下内容。
user 修改为root
server {
    # the port your site will be served on
    listen      8001;
    # the domain name it will serve for
    server_name .example.com; # substitute your machine's IP address or FQDN
    charset     utf-8;

# max upload size
    client_max_body_size 75M;   # adjust to taste
    location / {
        include uwsgi_params;
        uwsgi_pass 127.0.0.1:8000;
        uwsgi_read_timeout 2;
    }
    
    # Django static
    location /static {
        root /home/trcode/static; # your Django project's static files - amend as required
    }
    #Gridfs
    #[root_collection]: 选择collection,如root_collection=blog, mongod就会去找blog.files与blog.chunks两个块,默认是fs
    #[field]:查询字段,保证mongdb里有这个字段名,支持_id, filename, 可省略, 默认是_id
    #[type]:解释field的数据类型,支持objectid, int, string, 可省略, 默认是int
    #[user]:用户名, 可省略
    #[pass]:密码, 可省略
    location /file/ {
    gridfs trdb
        root_collection=fs
        field=_id
        type=objectid;
    #这里的mongo以slave模式启动会有问题?
    mongo 192.168.100.102:27017;
    }
    location /img/ {
    gridfs trdb
        root_collection=img
        field=_id
        type=objectid;
    #这里的mongo以slave模式启动会有问题?
    mongo 192.168.100.102:27017;
    }
}
/usr/local/nginx/sbin/nginx 启动
/usr/local/nginx/sbin/nginx -s reload 重启nginx,访问8001成功

killall  -9 uwsgi    关闭uwsgi进程

nginx1.4.7+uwsgi+django1.9.2+gridfs 在ubuntu14.0.4上部署的更多相关文章

  1. nginx1.4.7+uwsgi+django1.9.2项目部署,liunx系统为ubuntu14.0.4。

    本文基于root用户下进行部署,django项目名称为BDFS 1.  安装依赖包,终端输入命令 1)         环境依赖包 apt-get update apt-get install pyt ...

  2. Django线上部署教程:腾讯云+Ubuntu+Django+Uwsgi(转载)

    网站名称: 向东的笔记本 本文链接: https://www.eastnotes.com/post/29 版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议.转载请注明出处! ...

  3. CentOS上部署Django+Nginx+Uwsgi环境

    在CentOS上部署Django+Nginx+Uwsgi环境 奇谭  2016-09-01 评论  Linux  python django nginx uwsgi VirtualEnv的作用:创建隔 ...

  4. Django+Nginx+Uwsgi(全网最全步骤工作原理流程与部署历程)

    一.必要前提 1.1 准备知识 django 一个基于python的开源web框架,请确保自己熟悉它的框架目录结构. uWSGI 一个基于自有的uwsgi协议.wsgi协议和http服务协议的web网 ...

  5. Ubuntu16.04下部署 nginx+uwsgi+django1.9.7(虚拟环境pyenv+virtualenv)

    由于用的新版本系统,和旧的稍有差别,在网上搜了很多相关资料,搞了三天终于搞好在Ubuntu16.04下的部署,接下来就详细写写步骤以及其中遇到的问题.前提是安装有虚拟环境pyenv+virtualen ...

  6. ubuntu12上部署Django1.8.4+uwsgi+nginx超级详细流程配置到云服务器

    环境: 系统:ubuntu12,系统自带默认有python2.7 框架:Django1.8.4,需要python2.7以上才能支持   前言: 用户浏览器发送http请求->nginx(静态文件 ...

  7. nginx+uwsgi+django1.8.5配置

    http://jingyan.baidu.com/article/2d5afd69cdf6ad85a3e28e4f.html(搜索: wusgi 配置django1.8项目) http://my.os ...

  8. 在UOS 上部署 django + uwsgi + nginx 流程

    前言:这篇主要是流程,不喜勿喷,虽然我知道在部署过程中 参照博客写的越详细越好. 强大的百度会解决一切的 爬了诸多坑 ,心累,必须总结!! 最近 芯片封锁闹的很凶  支持国产!! UOS 统一操作系统 ...

  9. 基于nginx和uWSGI在Ubuntu上部署Djan

    http://www.jianshu.com/p/e6ff4a28ab5a 文/Gevin(简书作者)原文链接:http://www.jianshu.com/p/e6ff4a28ab5a著作权归作者所 ...

随机推荐

  1. lodash forIn forOwn 遍历对象属性

    _.forIn(object, [iteratee=_.identity]) 使用 iteratee 遍历对象的自身和继承的可枚举属性. function Foo() { this.a = 1; th ...

  2. jQuery控制form表单元素聚焦

      CreateTime--2017年5月28日08:57:16Author:Marydon jQuery使form表单的第一个文本框聚焦 /** * 使form表单的第一个文本框聚焦 */ func ...

  3. 【Python3 爬虫】04_urllib.request.urlretrieve

    urllib模块提供的urlretrieve()函数,urlretrieve()方法直接将远程的数据下载到本地 urllib语法 参数url:传入的网址,网址必须得是个字符串 参数filename:指 ...

  4. nginx只允许域名访问,禁止ip访问

    背景:为什么要禁止ip访问页面呢?这样做是为了避免其他人把未备案的域名解析到自己的服务器IP,而导致服务器被断网,我们可以通过禁止使用ip访问的方法,防止此类事情的发生. 解决方法:这里介绍修改配置文 ...

  5. MATLAB 的字符串分析

    MATLAB的字符串分析. 字符串实际上是指1Xn 的字符数组. MATLAB软件具有强大的字符串处理功能,提供了很多的字符或字符串处理函数,包括字符串的创建.字符串的属性.比较.查找以及字符串的转换 ...

  6. RabbitMQ消息队基本概念

    RabbitMQ简介 AMQP,即Advanced Message Queuing Protocol,高级消息队列协议,是应用层协议的一个开放标准,为面向消息的中间件设计.消息中间件主要用于组件之间的 ...

  7. 【CODEFORCES】 C. Table Decorations

    C. Table Decorations time limit per test 1 second memory limit per test 256 megabytes input standard ...

  8. Linux如何关机与关机命令祥解

    Linux关机命令祥解 1.直接关电源 2.init 0 3.telinit 0 4.shutdown -h now 5.halt6.poweroff 1.shutdown shutdown命令安全地 ...

  9. unity, iOS集成微信

    将微信sdk直接拖进xcode会导致Library Search Paths是错的,需要手动改成如下样子(蓝色选中部分)才能通过编译:

  10. C语言基础(13)-函数

    一. 函数的原型和调用 在使用函数前必须定义或者声明函数. double circle(double r); int main() { ); printf("length = %f\n&qu ...