: This article describes how to install and use the nginx-gridfs module. if you are interested in the PHP Tutorial, refer to it. Reference: http://www.open-open.com/lib/view/open1330171884015.html
Install and use the nginx-gridfs module
Project home: https://github.com/mdirolf/nginx-gridfs
Through nginx-gridfs, you can directly use http to access files in GridFS.
1. install
Install various dependent packages: zlib, pcre, and openssl
The following command may be used in ubuntu:
Sudo apt-get install zlib1g-dev // sudo apt-get install zlib-dev cannot be installed
Sudo apt-get install libpcre3 libpcre3-dev
Sudo apt-get install openssl libssl-dev
Install git (omitted)
Use git to download nginx-gridfs code:
Git clone git: // github.com/mdirolf/nginx-gridfs.git
Cd nginx-gridfs
Git submodule init
Git submodule update
Download nginx:
Wget http://nginx.org/download/nginx-1.0.12.zip
Tar zxvf nginx-1.0.12.zip
Cd nginx-1.0.12
./Configure -- add-module =
Make
Sudo make install
If a compilation error occurs, add the -- with-cc-opt =-Wno-error parameter to configure.
2. Configure nginx
Add the following to the server configuration:
Location/pics /{
Gridfs pics
Field = filename
Type = string;
Mongo 127.0.0.1: 27017;
}
The configuration above indicates:
The database is pics and the file is accessed by filename. The filename type is string.
Currently, only files can be accessed by id and filename.
Start nginx:/usr/local/nginx/sbin/nginx
Upload an image 001.jpg to the pics database with unzip vue.
Open: http: // localhost/pics/001.jpg
If the image is successfully displayed, the image is displayed.
3. nginx-gridfs deficiency
Http range support is not implemented, that is, resumable data transfer and multipart download.
The above introduces the installation and use of the nginx-gridfs module, including some content, and hope to be helpful to friends who are interested in the PHP Tutorial.