Read a picture of MongoDB with Nginx-gridfs

Source: Internet
Author: User
Tags install mongodb mongodb server openssl yum install mongodb git clone

First, install MongoDB

Create the/etc/yum.repos.d/mongodb.repo file with the following configuration file:

[Mongodb]name=mongodb repositorybaseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/gpgcheck=0enabled=1

Install MongoDB server and MongoDB shell.

$ sudo yum install mongodb-org-server-2.6.3 mongodb-org-shell-2.6.3

Configures the data storage path for MongoDB.

# mkdir/data/mongodb# Chown Mongod:mongod/data/mongodb

Modify the path of the/etc/mongod.conf configuration to point to.

# Configure database storage path DBPATH=/DATA/MONGODB

Start the MONGO service

$ sudo chkconfig mongod on$ sudo service mongod restart

Second, installation of Nginx and Nginx-gridfs

dependent libraries, tools

# yum-y Install pcre-devel openssl-devel zlib-devel# yum-y install gcc gcc-c++

Download Nginx-gridfs Source code

# git clone https://github.com/mdirolf/nginx-gridfs.git# cd nginx-gridfs# git checkout v0.8# git submodule init# git submo Dule Update

Download Nginx source code, compile and install.

# wget http://nginx.org/download/nginx-1.4.7.tar.gz# tar zxvf nginx-1.4.7.tar.gz# cd nginx-1.4.7#./configure-- With-openssl=/usr/include/openssl--add-module=. /nginx-gridfs/# make-j8 && Make Install-j8

Modify the/usr/local/nginx/conf/nginx.conf configuration file.

location/static/{Gridfs qrcode field=_id type=objectid;    #这里的mongo以slave模式启动会有问题? MONGO 127.0.0.1:27017;}

Start Nginx Service

#/usr/local/nginx/sbin/nginx

Third, testing

Upload a picture.

# sudo mongofiles put--host localhost--port 27017--db qrcode--local ~/photo.jpg--type jpg

Enter http://localhost/static/53db05cab177550d8613176f in the browser to open the picture, that means it's successful.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.