安裝nginx和nginx-gridfs和mongodb

來源:互聯網
上載者:User

標籤:checkout   接收   system   tool   roo   tps   database   ever   define   

1.安裝依賴包:

[[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#子模組 ‘mongo-c-driver‘ (git://github.com/mongodb/mongo-c-driver.git) 已為路徑 ‘mongo-c-driver‘ 註冊[[email protected]_rs1 nginx-gridfs]# git submodule update正複製到 ‘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接收對象中: 100% (101193/101193), 49.45 MiB | 4.55 MiB/s, done.處理 delta 中: 100% (88309/88309), done.子模組路徑 ‘mongo-c-driver‘:檢出 ‘74cc0b8005fbbc84ec4a0003ff80c68f9e9cc7de‘

 

2.安裝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#把第3行的-Werror錯誤去掉[[email protected]_rs1 nginx-1.7.9]# vi objs/Makefile [[email protected]_rs1 nginx-1.7.9]# make && make install

3.修改設定檔

[[email protected]_rs1 nginx-1.7.9]# vi /usr/local/nginx/conf/nginx.conf#添加以下內容        location /girdfstest/ {            gridfs pics            field=_id            type=objectid;            mongo 127.0.0.1:27017;        }
#gridfstest:訪問地址

#pics:資料庫

#mongo 127.0.0.1:10001 #mongo的伺服器位址及連接埠
#啟動nginx[[email protected]_rs1 nginx-1.7.9]# /usr/local/nginx/sbin/nginx#配置修改後重新載入[[email protected]_rs1 nginx-1.7.9]# /usr/local/nginx/sbin/nginx -s reload

4.安裝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 查看修改設定檔 : vim /etc/mongod.conf啟動mongodb :systemctl start mongod.service停止mongodb :systemctl stop mongod.service

如果報錯:

[[email protected] nginx-1.7.9]# journalctl -xe7月 11 10:54:03 ansible.test yum[797]: Erased: mongodb-org-3.2.20-1.el7.x86_647月 11 10:54:04 ansible.test systemd[1]: Reloading.7月 11 10:54:04 ansible.test systemd[1]: Configuration file /usr/lib/systemd/system/ebtables.service is marked executable. Ple7月 11 10:54:04 ansible.test systemd[1]: Configuration file /usr/lib/systemd/system/wpa_supplicant.service is marked executabl7月 11 10:54:04 ansible.test yum[797]: Erased: mongodb-org-server-3.2.20-1.el7.x86_647月 11 10:54:04 ansible.test yum[797]: Erased: mongodb-org-shell-3.2.20-1.el7.x86_647月 11 10:54:04 ansible.test yum[797]: Erased: mongodb-org-mongos-3.2.20-1.el7.x86_647月 11 10:54:04 ansible.test yum[797]: Erased: mongodb-org-tools-3.2.20-1.el7.x86_647月 11 10:59:08 ansible.test systemd[1]: Reloading.7月 11 10:59:08 ansible.test systemd[1]: Configuration file /usr/lib/systemd/system/ebtables.service is marked executable. Ple7月 11 10:59:08 ansible.test systemd[1]: Configuration file /usr/lib/systemd/system/wpa_supplicant.service is marked executabl7月 11 10:59:08 ansible.test yum[928]: Installed: mongodb-org-server-3.2.20-1.el7.x86_647月 11 10:59:08 ansible.test yum[928]: Installed: mongodb-org-mongos-3.2.20-1.el7.x86_647月 11 10:59:12 ansible.test yum[928]: Installed: mongodb-org-tools-3.2.20-1.el7.x86_647月 11 10:59:13 ansible.test yum[928]: Installed: mongodb-org-shell-3.2.20-1.el7.x86_647月 11 10:59:13 ansible.test yum[928]: Installed: mongodb-org-3.2.20-1.el7.x86_647月 11 10:59:21 ansible.test polkitd[747]: Registered Authentication Agent for unix-process:961:41855579 (system bus name :1.17月 11 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月 11 10:59:21 ansible.test mongod[966]: Error starting mongod. /var/run/mongodb/mongod.pid exists.7月 11 10:59:21 ansible.test systemd[1]: mongod.service: control process exited, code=exited status=17月 11 10:59:21 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.使用mongofiles工具

[[email protected]_rs1 tmp]# mongofiles  put 1.JPG -d pics -t jpg 2018-07-11T11:34:16.002+0800    connected to: localhostadded file: 1.JPG[[email protected]_rs1 tmp]# mongofiles list -d pics2018-07-11T11:34:33.037+0800    connected to: localhost1.JPG   138424[[email protected]_rs1 tmp]# 

6.http訪問:

http://172.16.160.91/girdfstest/1.jpg

 

安裝nginx和nginx-gridfs和mongodb

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.