• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

nginx 连接 mongodb

php 搞代码 3年前 (2022-01-23) 10次浏览 已收录 0个评论

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.@本文9来源gao($daima.com搞@代@#码8网^搞代gaodaima码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教程有兴趣的朋友有所帮助。


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:nginx 连接 mongodb

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址