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 initgit 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;
- }
- }
时间: 2024-11-12 09:15:36