nginx connect mongodb

WBOY
Release: 2016-07-29 09:04:41
Original
1395 people have browsed it

1)、 下载nginx-gridfs的代码

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

以上就介绍了nginx 连接 mongodb,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template