Nginx+nginx-gridfs 太过爱你忘了你带给我的痛 2022-08-21 08:44 177阅读 0赞 [Nginx+nginx-gridfs][Nginx_nginx-gridfs] [转至元数据结尾][Link 1] · Created and last modified by [admi][] on [四月 29, 2015][29_ 2015] [转至元数据起始][Link 2] 为了实现mongodb的http直接访问采用此方式进行配置 1、安装**mongoDB6.2.9 详见:**[mongoDB安装][mongoDB] 2、安装依赖库 yum -y install pcre-devel openssl-devel zlib-devel yum -y install gcc gcc-c++ 3、下载nginx-gridfs源码: 进入:/opt/ 目录 <table> <tbody> <tr> <td style="background:#F0F0F0"> <p><strong><span style="color:#333333"> git clone </span></strong><a href="https://github.com/mdirolf/nginx-gridfs.git" rel="nofollow"><strong><span style="color:#3B73AF">https://github.com/mdirolf/nginx-gridfs.git</span></strong></a><strong><span style="color:#333333"> </span><span style="color:#333333">(如果找不到git</span>命令,yum -install git 安装)</strong></p> <p><strong><span style="color:#333333"> cd nginx-gridfs</span></strong></p> <p><strong><span style="color:#333333"> git checkout v0.8</span></strong></p> <p><strong><span style="color:#333333"> git submodule init</span></strong></p> <p><strong><span style="color:#333333"> git submodule update</span></strong></p> </td> </tr> </tbody> </table> 4、下载nginx源码,编译安装 进行: /opt/ 目录 <table> <tbody> <tr> <td style="background:#F0F0F0"> <p><strong> wget </strong><a href="http://nginx.org/download/nginx-1.8.0.tar.gz" rel="nofollow"><strong><span style="color:black">http://nginx.org/download/nginx-1.8.0.tar.gz</span></strong></a><strong>(如果找不到wget命令,yum -install wget 安装)</strong></p> <p><strong> tar zxvf nginx-</strong><a href="http://nginx.org/download/nginx-1.8.0.tar.gz" rel="nofollow"><strong><span style="color:black">1.8.0</span></strong></a><strong>.tar.gz</strong></p> <p><strong> cd nginx-</strong><a href="http://nginx.org/download/nginx-1.8.0.tar.gz" rel="nofollow"><strong><span style="color:black">1.8.0</span></strong></a></p> <p><strong> ./configure --with-openssl=/usr/include/openssl --add-module=../nginx-gridfs/</strong></p> <p><strong> make -j8 && make install -j8</strong></p> </td> </tr> </tbody> </table> 5、修改/usr/local/nginx/conf/nginx.conf配置文件。 找到文件的\[server\] 80 端口处添加: <table> <tbody> <tr> <td style="background:#F0F0F0"> <p><strong><span style="color:#333333">location /files/ { <br> gridfs fsfile<br> field=filename<br> type=string;<br> mongo 127.0.0.1:27017;<br> }</span></strong></p> </td> </tr> </tbody> </table> mongo127.0.0.1:27017; 表示mongo的安装在同一个服务器 6、启动nginx服务: /usr/local/nginx/sbin/./nginx -c /usr/local/nginx/conf/nginx.conf 7、测试 通过mongodb添加一个文件,然后在地址栏输入: [http://192.168.1.201/files/news002.jpg][http_192.168.1.201_files_news002.jpg] 将显示图片内容 8、关闭nginx服务 通过 kill命令关闭 [Nginx_nginx-gridfs]: http://192.168.1.202:6070/pages/viewpage.action?pageId=524315 [Link 1]: http://192.168.1.202:6070/pages/viewpage.action?pageId=524315#page-metadata-end [admi]: http://192.168.1.202:6070/display/~admin [29_ 2015]: http://192.168.1.202:6070/pages/diffpagesbyversion.action?pageId=524315&selectedPageVersions=4&selectedPageVersions=5 [Link 2]: http://192.168.1.202:6070/pages/viewpage.action?pageId=524315#page-metadata-start [mongoDB]: http://192.168.1.202:6070/pages/viewpage.action?pageId=524310 [http_192.168.1.201_files_news002.jpg]: http://192.168.1.201/files/news002.jpg
还没有评论,来说两句吧...