nginx 串連 mongodb

來源:互聯網
上載者:User
1)、 下載nginx-gridfs的代碼

2)、安裝 最新版 pcre

從https://sourceforge.net/projects/pcre/files/pcre/ 下載最新版 pcre

# unzip pcre-8.38.zip

# cd pcre-8.38

# ./configure --prefix=/usr/local/pcre-8.38 --libdir=/usr/local/lib/pcre --includedir=/usr/local/include/pcre

# make && make install

3)、安裝 nginx

# yum -y install gcc* openssl*

# tar zxf nginx-1.7.7.tar.gz

# cd nginx-1.7.7

# ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-http_flv_module --with-http_gzip_static_module --add-module=/usr/src/nginx-gridfs --with-poll_module --without-select_module --with-http_realip_module --with-pcre=/usr/src/pcre-8.38

此處編譯的時候必須要指定 源碼檔案,否則會在 make 的時候報錯:

/bin/sh: line 2: ./configure: No such file or directory
make[1]: *** [/usr/local/pcre/Makefile] Error 127
make[1]: Leaving directory `/usr/local/src/nginx-0.8.54′

make: *** [build] Error 2

# make && make install

4)、啟動 nginx

# /usr/local/nginx/sbin/nginx

# ps -ef | grep nginx

# netstat -nlp | grep nginx

# curl http://localhost

顯示歡迎頁面,此時nginx 搭建成功

5)、配置 nginx

# vim /usr/local/nginx/conf/nginx.conf

location /pics/ {

gridfs pics root_collection=fs field=filename type=string -upics -ppics;

mongo 127.0.0.1:27017;

}

6)、mongodb 上傳圖片

#mongofiles put 1.jpg -d pics -t jpg -upics -ppics

# mongofiles list -d pics -upics -ppics

7)、curl 下

curl http://localhost/pics/1.jpg

以上就介紹了nginx 串連 mongodb,包括了方面的內容,希望對PHP教程有興趣的朋友有所協助。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.