首页 > 代码库 > nginx 支持mongodb的编译安装和配置
nginx 支持mongodb的编译安装和配置
nginx支持mongodb需要添加模块进行编译安装,步骤如下:
安装pcre-devel
sudo apt-get install libpcre3 libpcre3-dev
sudo apt-get install openssl libssl-dev安装nginx-gridfs
git clone git://github.com/mdirolf/nginx-gridfs.git
cd nginx-gridfs/
git submodule init
git submodule update
cd /data/soft/nginx-1.6.2 (此处为下载好的nginx源码目录)
./configure --add-module=/data/soft/nginx-gridfs (此处为上面git下载的gridfs的目录)
make
make install修改nginx的conf文件
server {
listen 80;
server_name s1.111du.com;
//所有请求都映射到mongodb的服务中
location / {
//通过field=filename来做数据查询
gridfs imark field=filename type=string;
//mongodb的服务
mongo 127.0.0.1:30001;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# deny access to .htaccess files, if Apache‘s document root
# concurs with nginx‘s one
#
location ~ /WEB-INF/ {
deny all;
}
}
本文出自 “我爱CTO” 博客,请务必保留此出处http://tanjunjie.blog.51cto.com/6988/1579626
nginx 支持mongodb的编译安装和配置