Still waiting to be updated ...
1. Prepare the Package
Nginx-1.4.7.tar.gz
Nginx-gridfs.tar.gz
Mongodb-linux-x86_64-rhel62-2.7.7.tgz
The address is as follows:
Http://nginx.org/download/nginx-1.4.7.tar.gz
Http://pan.baidu.com/s/1mgpiOmG
Http://downloads.mongodb.org/linux/mongodb-linux-x86_64-rhel62-2.7.7.tgz
2. Decompression and Installation
Tar XF nginx-1.4.7.tar.gz
Tar XF nginx-gridfs.tar.gz
3. Installation relies on adding users and compiling
CD nginx-1.4.7/
Yum-y Install Pcre-devel openssl-devel zlib-devel
Useradd nginx-s/sbin/nologin-m
./configure--prefix=/etc/nginx--sbin-path=/usr/sbin/nginx--conf-path=/etc/nginx/nginx.conf--with-http_stub_ Status_module--with-http_ssl_module--with-poll_module--add-module=/root/nginx-gridfs--user=nginx--group=nginx
4. Handle errors in Makefile and install
Vim Objs/makefile
Remove the-werror from the third row
Make &&make Install
5. Installing MongoDB
Tar XF mongodb-linux-x86_64-rhel62-2.7.7.tgz-c/usr/local/
cd/usr/local/ MV mongodb-linux-x86_64-rhel62-2.7.7 MongoDB
Mkdir/usr/local/mongodb/data
Vim/usr/local/mongodb/mongodb.conf
#端口
port=27017
#数据文件存放目录
Dbpath=/usr/local/mongodb/data
#日志文件存放目录
Logpath=/usr/local/mongodb/mongodb.log
#使用追加的方式写日志
Logappend=true
#以守护程序的方式启用, which runs in the background
Fork=true
#最大同时连接数
maxconns=500
#只允许通过本机访问
#bind_ip =127.0.0.1
#启用验证
#auth = True
6. Configure Environment variables
Echo ' Export path= $PATH:/usr/local/mongodb/bin ' >>/etc/profile
. /etc/profile
7. Start MongoDB
/usr/local/mongodb/bin/mongod-f/usr/local/mongodb/mongodb.conf
8. Add a picture to MongoDB (photo.jpg in the current directory)
Mongofiles put photo.jpg-h127.0.0.1:27017-d my_app-t jpg
9. Configure Nginx access to MongoDB
location/abc/{
Gridfs My_app root_collection=fs field=filename type=string;
#--my_app is a database in MongoDB, root_collection is a table prefix, field is a file accessed by file name, type is the kind of file name stored
MONGO 127.0.0.1:27017;
IP and port for #--mongodb
}
10. Restart Nginx and visit 192.168.1.219/abc/photo.jpg
11. Precautions
1) Nginx version does not matter, but Gridfs third-party module plug-in to correct, otherwise nginx error log will be reported not connected to MongoDB errors
2) MongoDB version can not be higher than 3.0, I use the 2.7, if too high, Nginx Error.log will appear memory overflow error malloc (18446744056529682432) failed
3) After the configuration compiled to remove Werror to continue to make, or will error
4) Nginx replacement version without deleting, recompile can
5) Close MongoDB please go to database using Method Db.shutdownserver () Close the database
This article is from the "Mountain King" blog, please make sure to keep this source http://chenshifei.blog.51cto.com/11883413/1857685
Installing Nginx+gridfs+mongodb