nginx 支持mongodb的编译安装和配置

nginx支持mongodb须要添加模块进行编译安装,步骤以下:

  • 安装pcre-devel 
    sudo apt-get install libpcre3 libpcre3-dev
    sudo apt-get install openssl libssl-dev

    html

  • 安装nginx-gridfs
    git clone git://github.com/mdirolf/nginx-gridfs.git
    cd nginx-gridfs/
    git submodule init  nginx


    git submodule update git


    cd /data/soft/nginx-1.6.2  (此处为下载好的nginx源码目录)github


    ./configure --add-module=/data/soft/nginx-gridfs  (此处为上面git下载的gridfs的目录)mongodb


    make
    make installide

  • 修改nginx的conf文件spa

  1. server {  orm

  2.         listen       80;  server

  3.         server_name s1.111du.com;  htm

  4.   

  5.         //全部请求都映射到mongodb的服务中  

  6.         location / {  

  7.             //经过field=filename来作数据查询  

  8.             gridfs imark field=filename type=string;  

  9.             //mongodb的服务  

  10.             mongo 127.0.0.1:30001;  

  11.         }  

  12.   

  13.         # redirect server error pages to the static page /50x.html  

  14.         #  

  15.         error_page   500 502 503 504  /50x.html;  

  16.         location = /50x.html {  

  17.             root   html;  

  18.         }  

  19.   

  20.         # deny access to .htaccess files, if Apache's document root  

  21.         # concurs with nginx's one  

  22.         #  

  23.         location ~ /WEB-INF/ {  

  24.             deny  all;  

  25.         }  

  26.     }

相关文章
相关标签/搜索