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.