1.安装依赖包

  1. yum -y install pcre-devel openssl-devel zlib-devel git gcc gcc-c++
  2. git clone https://github.com/mdirolf/nginx-gridfs.git
  3. cd nginx-gridfs/
  4. git checkout v0.8
  5. git branch
  6. git submodule init
  7. git submodule update

2.安装nginx

  1. wget http://nginx.org/download/nginx-1.7.9.tar.gz
  2. tar -zxvf nginx-1.7.9.tar.gz
  3. cd nginx-1.7.9/
  4. ./configure --prefix=/usr/local/nginx --with-openssl=/usr/include/openssl --add-module=/usr/local/nginx-gridfs
  5. make && make install

3.修改配置文件

  1. vi /usr/local/nginx/conf/nginx.conf
  2. #添加以下内容
  3. location /voice/ {
  4. gridfs vtest root_collection=fs;
  5. mongo 127.0.0.1:27017;
  6. }
  7. location /package/ {
  8. gridfs vtest root_collection=vp;
  9. mongo 127.0.0.1:27017;
  10. }
  11. #修改完毕以后,启动nginx
  12. /usr/local/nginx/sbin/nginx
  13. #配置修改后重新加载
  14. /usr/local/nginx/sbin/nginx -s reload

4.安装mongodb

  1. vi /etc/yum.repos.d/mongodb-org-3.4.repo
  2. [mongodb-org-3.4]
  3. name=MongoDB Repository
  4. baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/
  5. gpgcheck=0
  6. enabled=1
  7. gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc
  8. $ yum -y install mongodb-org
  9. 查看修改配置文件 vim /etc/mongod.conf<br>mongodb的配置文件中的bind_ip 默认为127.0.0.1,默认只有本机可以连接。 此时,需要将bind_ip配置为0.0.0.0,表示接受任何IP的连接。
  10. 启动mongodb systemctl start mongod.service
  11. 停止mongodb systemctl stop mongod.service

安装如果出错

  1. journalctl -xe
  2. 7 11 10:54:03 ansible.test yum[797]: Erased: mongodb-org-3.2.20-1.el7.x86_64
  3. 7 11 10:54:04 ansible.test systemd[1]: Reloading.
  4. 7 11 10:54:04 ansible.test systemd[1]: Configuration file /usr/lib/systemd/system/ebtables.service is marked executable. Ple
  5. 7 11 10:54:04 ansible.test systemd[1]: Configuration file /usr/lib/systemd/system/wpa_supplicant.service is marked executabl
  6. 7 11 10:54:04 ansible.test yum[797]: Erased: mongodb-org-server-3.2.20-1.el7.x86_64
  7. 7 11 10:54:04 ansible.test yum[797]: Erased: mongodb-org-shell-3.2.20-1.el7.x86_64
  8. 7 11 10:54:04 ansible.test yum[797]: Erased: mongodb-org-mongos-3.2.20-1.el7.x86_64
  9. 7 11 10:54:04 ansible.test yum[797]: Erased: mongodb-org-tools-3.2.20-1.el7.x86_64
  10. 7 11 10:59:08 ansible.test systemd[1]: Reloading.
  11. 7 11 10:59:08 ansible.test systemd[1]: Configuration file /usr/lib/systemd/system/ebtables.service is marked executable. Ple
  12. 7 11 10:59:08 ansible.test systemd[1]: Configuration file /usr/lib/systemd/system/wpa_supplicant.service is marked executabl
  13. 7 11 10:59:08 ansible.test yum[928]: Installed: mongodb-org-server-3.2.20-1.el7.x86_64
  14. 7 11 10:59:08 ansible.test yum[928]: Installed: mongodb-org-mongos-3.2.20-1.el7.x86_64
  15. 7 11 10:59:12 ansible.test yum[928]: Installed: mongodb-org-tools-3.2.20-1.el7.x86_64
  16. 7 11 10:59:13 ansible.test yum[928]: Installed: mongodb-org-shell-3.2.20-1.el7.x86_64
  17. 7 11 10:59:13 ansible.test yum[928]: Installed: mongodb-org-3.2.20-1.el7.x86_64
  18. 7 11 10:59:21 ansible.test polkitd[747]: Registered Authentication Agent for unix-process:961:41855579 (system bus name :1.1
  19. 7 11 10:59:21 ansible.test systemd[1]: Starting SYSV: Mongo is a scalable, document-oriented database....
  20. -- Subject: Unit mongod.service has begun start-up
  21. -- Defined-By: systemd
  22. -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
  23. --
  24. -- Unit mongod.service has begun starting up.
  25. 7 11 10:59:21 ansible.test mongod[966]: Error starting mongod. /var/run/mongodb/mongod.pid exists.
  26. 7 11 10:59:21 ansible.test systemd[1]: mongod.service: control process exited, code=exited status=1
  27. 7 11 10:59:21 ansible.test systemd[1]: Failed to start SYSV: Mongo is a scalable, document-oriented database..
  28. #解决方法:
  29. rm /var/run/mongodb/mongod.pid -f
  30. systemctl start mongod.service

5.使用mongofiles工具进行测试

  1. [root@localhost local]# mongofiles put 1.png -d vtest -t png
  2. 2019-07-22T23:37:11.546-0700 connected to: localhost
  3. added file: 1.png
  4. [root@localhost local]# mongofiles list -d vtest
  5. 2019-07-22T23:38:31.949-0700 connected to: localhost
  6. 1.png 566915
  7. [root@localhost local]# mongofiles -d vtest get 1.png
  8. 2019-07-22T23:38:56.741-0700 connected to: localhost
  9. finished writing to: 1.png

安装nginx + nginx-gridfs + mongodb的更多相关文章

  1. CentOS6.3搭建Nginx代理访问MongoDB GridFS图片资源

    PHP可以直接读取MongoDB GridFS中的图片并显示到页面中,但对PHP的压力就大了.偶然机会,了解到Nginx可以代理访问,实现过程如下: 1.工具准备 安装一些必要的编译工具及库,这里是直 ...

  2. centOS7下 安装nodejs+nginx+mongodb+pm2部署vue项目

    一.购买服务器并远程连接 1.购买服务器和域名 可以选择阿里云或者是其他的厂商的服务器.然后会获得服务器ip地址,用户名和密码. 购买域名,将域名绑定到ip地址上. 2.下载xshell,winscp ...

  3. nginx+play framework +mongoDB+redis +mysql+LBS实战总结

    nginx+play framework +mongoDB+redis +mysql+LBS实战总结(一) 使用这个样的组合结构已经很久了,主要是实现web-server,不是做网站,二是纯粹的数据服 ...

  4. centos7.4下搭建JDK+Tomcat+Nginx+Mysql+redis+Mongodb+maven+Git+Jenkins

    先干两件大事!先干两件大事!先干两件大事! 1.关闭selinux [root@mycentos ~]# vi /etc/selinux/config SELINUX=disabled 2.关闭防火墙 ...

  5. CentOS6编译安装PHP7+Nginx

    本文属于动手搭建PHP开发环境的一部分,更多点击链接查看. 本文以centos6为例. 安装PHP 下载 http://cn2.php.net/distributions/php-5.6.22.tar ...

  6. centos 系统下安装FastDFS+nginx+fastdfs-nginx-module安装配置

    前言: 以前的项目上传的文件都是保存到本地或者是局域网内的共享文件夹下,由于数据量,服务器的负载均衡(分机的某些图片无法访问的问题处理)等因素的情况下,就想到用fastdfs来文件管理,花了几天时间硬 ...

  7. centos6.4下安装php7+nginx+mariadb环境

    一,安装php71,创建php用户和用户组,并在github下载php7源码#新建php用户和php组# groupadd -r php && useradd -r -g php -s ...

  8. linux安装php & nginx

    1.安装libxml2 地址:http://ftp.gnome.org/pub/GNOME/sources/libxml2/ wget http://caesar.acc.umu.se/pub/GNO ...

  9. Cenos7 编译安装 Mariadb Nginx PHP Memcache ZendOpcache (实测 笔记 Centos 7.0 + Mariadb 10.0.15 + Nginx 1.6.2 + PHP 5.5.19)

    环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7.0-1406-x86_64-DVD.iso 安装步骤: 1.准备 1.1 显示系统版 ...

  10. linux 安装配置Nginx

    简介: Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like 协议下发行.由俄罗斯的程序设计师Igor Sysoev所开发,供俄国 ...

随机推荐

  1. springmvc@RequestMapping-params参数规则

    springmvc@RequestMapping-params参数规则 https://blog.csdn.net/qq_33439525/article/details/78193190 版权声明: ...

  2. Chrome禁用software_reporter_tool

    今天开机后,从几分钟到半个小时之间,感觉机器反应有些慢,发现CPU占用80-90%.查看任务管理器, 有一个 software_reporter_tool.exe 的程序占用了一半的CPU使用率. 转 ...

  3. c++ Array运用实例

    myprint.hpp #include <iostream> #include <string> template <typename T> inline voi ...

  4. npm link用法总结

    npm link用来在本地项目和本地npm模块之间建立连接,可以在本地进行模块测试 具体用法: 1. 项目和模块在同一个目录下,可以使用相对路径 npm link ../module 2. 项目和模块 ...

  5. Mac mysql 忘记root密码的解决方法

    1.执行命令以安全模式启动MySQL cd /usr/local/mysql/bin sudo ./mysqld_safe --skip-grant-tables 2.同上面目录下执行 '\) whe ...

  6. EasyNVR网页摄像机无插件H5、谷歌Chrome直播方案-Onvif(二)使用Onvif协议进行设备RTSP地址获取

    背景介绍 EasyNVR最大的优势就是兼容性,通过RTSP协议接入传统网络摄像机.NVR.编码器等,使用RTSP协议接入能兼容市面上绝大多数网络摄像机等源设备,最大程度的提高整体方案的硬件设备的兼容性 ...

  7. Windows SVN迁移到Linux 服务器

    一.备份VisualSVN项目 1. 现在要使用Linux作为svn服务器,之前是在windows Server 2008上的,用的是VisualSVN, 如下图所示. 2. 现在svn中有一个项目f ...

  8. [LeetCode] 737. Sentence Similarity II 句子相似度 II

    Given two sentences words1, words2 (each represented as an array of strings), and a list of similar ...

  9. C# .net 提升 asp.net mvc, asp.net core mvc 并发量

    1.提升System.Net.ServicePointManager.DefaultConnectionLimit 2.提升最小工作线程数 ------ DefaultConnectionLimit在 ...

  10. Tomcat总结四种部署方式

    静态部署 一.Webapps 把项目复制到Tomcat的Webapps 把war包复制到Tomcat的Webapps下 *修改Webapps的默认路径: * Tomcat的conf目录下的server ...