1. Install the dependent packages:
[[Email protected]_rs1 ~]# yum-y install pcre-devel openssl-devel zlib-devel git gcc gcc-c++
[[Email protected]_rs1 zhuyr]# git clone https://github.com/mdirolf/nginx-gridfs.git[[email protected]_rs1 zhuyr]# CD Nginx-gridfs/[[email protected]_rs1 nginx-gridfs]# git checkout v0.8[[email protected]_rs1 nginx-gridfs]# git branch[[ Email protected]_rs1 nginx-gridfs]# git submodule init# sub-module ' Mongo-c-driver ' (git://github.com/mongodb/ MONGO-C-DRIVER.GIT) has been registered for the path ' mongo-c-driver ' [[email protected]_rs1 nginx-gridfs]# git submodule update is being cloned to ' Mongo-c-driver ' ... remote:counting objects:101193, done.remote:Compressing objects:100% (128/128), done.remote:Total 101193 (Delta 159), reused 195 (Delta 127), pack-reused 100938 receiving object: 100% (101193/101193), 49.45 MiB | 4.55 mib/s, done. Processing Delta: 100% (88309/88309), do. Sub-module path ' mongo-c-driver ': Checkout ' 74cc0b8005fbbc84ec4a0003ff80c68f9e9cc7de '
2. Installing Nginx
[Email protected]_rs1 zhuyr]# wget http://nginx.org/download/nginx-1.7.9.tar.gz[[email protected]_rs1 zhuyr]# TAR-ZXVF nginx-1.7.9.tar.gz[[email protected]_rs1 zhuyr]# cd nginx-1.7.9/[[email protected]_rs1 nginx-1.7.9]#. Configure--prefix=/usr/local/nginx --with-openssl=/usr/include/openssl--add-module=/zhuyr/nginx-gridfs[[ Email protected]_rs1 nginx-1.7.9]# make-j8 && make Install-j8
#如果报错 [[Email protected]_rs1 nginx-1.7.9]#/configure--prefix=/usr/local/nginx --with-openssl=/usr/include/ OpenSSL--add-module=/zhuyr/nginx-gridfs# to remove the-werror error from line 3rd [[email protected]_rs1 nginx-1.7.9]# VI objs/makefile [[ Email protected]_rs1 nginx-1.7.9]# make && make install
3. Modify the configuration file
[[Email protected]_rs1 nginx-1.7.9]# vi/usr/local/nginx/conf/nginx.conf# Add the following location/girdfstest/{ Gridfs pics field=_id type=objectid; MONGO 127.0.0.1:27017; }
#gridfstest: Access Address
#pics: Database
#mongo 127.0.0.1:10001 #mongo的服务器地址及端口
#启动nginx [[Email protected]_rs1 nginx-1.7.9]#/usr/local/nginx/sbin/nginx# Configuration modified reload [email protected]_rs1 nginx-1.7.9]#/usr/local/nginx/sbin/nginx-s Reload
4. Installing MongoDB
Vi/etc/yum.repos.d/mongodb-org-3.4.repo [mongodb-org-3.4] name=mongodb Repository baseurl=https:// repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/ gpgcheck=0 enabled=1 Gpgkey=https ://WWW.MONGODB.ORG/STATIC/PGP/SERVER-3.4.ASC $ yum-y Install mongodb-org View Modify configuration file: Vim/etc/mongod.conf start MongoDB : Systemctl start Mongod.service stop Mongodb:systemctl stop Mongod.service
If error:
[[email protected] nginx-1.7.9]# journalctl-xe7 month 10:54:03 ansible.test yum[797]: erased: mongodb-org-3.2.20-1.el7.x86_647 month 10:54:04 ansible.test systemd[1]: reloading.7 month 10:54:04 ansible.test systemd[1] : Configuration File/usr/lib/systemd/system/ebtables.service is marked executable. Ple7 month 10:54:04 ansible.test systemd[1]: Configuration file/usr/lib/systemd/system/wpa_supplicant.service is marked EXECUTABL7 month 10:54:04 ansible.test yum[797]: erased:mongodb-org-server-3.2.20-1.el7.x86_647 Month 11 10:54:04 Ansible.test yum[797]: erased:mongodb-org-shell-3.2.20-1.el7.x86_647 month 10:54:04 ansible.test yum[797]: Erased: mongodb-org-mongos-3.2.20-1.el7.x86_647 month 10:54:04 ansible.test yum[797]: erased: mongodb-org-tools-3.2.20-1.el7.x86_647 month 10:59:08 ansible.test systemd[1]: reloading.7 month 10:59:08 ansible.test SYSTEMD[1]: Configuration file/usr/lib/systemd/system/ebtables.service is marked executable. Ple7 month 10:59:08 ansible.test systemd[1]: Configuration file/usR/lib/systemd/system/wpa_supplicant.service is marked EXECUTABL7 month one 10:59:08 ansible.test yum[928]: installed: mongodb-org-server-3.2.20-1.el7.x86_647 month 10:59:08 ansible.test yum[928]: installed: mongodb-org-mongos-3.2.20-1.el7.x86_647 month 10:59:12 ansible.test yum[928]: installed: mongodb-org-tools-3.2.20-1.el7.x86_647 month 10:59:13 ansible.test yum[928]: installed: mongodb-org-shell-3.2.20-1.el7.x86_647 month 10:59:13 ansible.test yum[928]: installed:mongodb-org-3.2.20-1.el7.x86_ 647 month 10:59:21 Ansible.test polkitd[747]: Registered authentication Agent for unix-process:961:41855579 (System bus Name : 1.17 months 10:59:21 Ansible.test systemd[1]: Starting Sysv:mongo is a scalable, document-oriented database....--Subject: Unit Mongod.service has begun start-up--defined-by:systemd--support:http://lists.freedesktop.org/mailman/listinfo/ Systemd-devel----Unit Mongod.service has begun starting UP.7 month one 10:59:21 ansible.test mongod[966]: Error starting MONGO D./var/run/mongodb/mongod.pID exists.7 Month 10:59:21 ansible.test systemd[1]: Mongod.service:control process exited, code=exited status=17 month 11 10:59: Ansible.test systemd[1]: Failed to start Sysv:mongo is a scalable, document-oriented database.
#解决方法: [[email protected] mongodb]# rm/var/run/mongodb/mongod.pid-f[[email protected] mongodb]# systemctl start Mongod.service
5. Using the Mongofiles tool
[[Email protected]_rs1 tmp]# mongofiles put 1.jpg-d pics-t JPG 2018-07-11t11:34:16.002+0800 connected to:local hostadded file:1.jpg[[email protected]_rs1 tmp]# mongofiles list-d pics2018-07-11t11:34:33.037+0800 connected to: Localhost1. Jpg
6.http Access:
Http://172.16.160.91/girdfstest/1.jpg
Installing Nginx and Nginx-gridfs and MongoDB