nginx 连接 mongodb

1)、 下载nginx-gridfs的代码
http://pan.baidu.com/s/1pKxgu1t

2)、安装 最新版  pcre
     从 https://sourceforge.net/projects/pcre/files/pcre/ 下载最新版 pcre
     # unzip pcre-8.38.zip
     # cd pcre-8.38
     # ./configure --prefix=/usr/local/pcre-8.38 --libdir=/usr/local/lib/pcre --includedir=/usr/local/include/pcre
     # make && make install

3)、安装 nginx 
# yum -y install gcc* openssl*
# tar zxf nginx-1.7.7.tar.gz
# cd nginx-1.7.7
./configure --prefix=/usr/local/nginx  --with-http_ssl_module --with-http_stub_status_module --with-http_flv_module --with-http_gzip_static_module --add-module=/usr/src/nginx-gridfs --with-poll_module --without-select_module --with-http_realip_module  --with-pcre=/usr/src/pcre-8.38
     此处编译的时候必须要指定 源码文件,否则会在 make 的时候报错:
/bin/sh: line 2: ./configure: No such file or directory 
make[1]: *** [/usr/local/pcre/Makefile] Error 127 
make[1]: Leaving directory `/usr/local/src/nginx-0.8.54′ 
make: *** [build] Error 2
# make && make install

4)、启动 nginx
# /usr/local/nginx/sbin/nginx
# ps -ef | grep nginx
# netstat -nlp | grep nginx
# curl http://localhost

显示欢迎页面,此时nginx 搭建成功

5)、配置 nginx 
# vim /usr/local/nginx/conf/nginx.conf
 location /pics/ {
                gridfs pics root_collection=fs field=filename type=string -upics -ppics;
                mongo 127.0.0.1:27017;
 }
6)、mongodb 上传图片
# mongofiles put 1.jpg -d pics -t jpg -upics -ppics
# mongofiles list -d pics  -upics -ppics

7)、curl 下
curl http://localhost/pics/1.jpg
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值