標籤:nginx mongodb nginxgridfs
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的編譯安裝和配置