前提:已成功安裝fastdfs,詳見centos7下安裝fastdfs
參考:Centos7 安裝FastDFS+nginx module
1.安裝工具
2.下載下傳解壓安裝包
wget https://github.com/happyfish100/fastdfs-nginx-module/archive/master.zip
unzip master.zip
wget http://nginx.org/download/nginx-.tar.gz
tar -zxv -f nginx-.tar.gz
3.安裝nginx
mv nginx- /usr/local/
cd /usr/local/nginx-
./configure --add-module=/root/fdfs/fastdfs-nginx-module-master/src/ --prefix=/usr/local/nginx --user=nobody --group=nobody --with-http_gzip_static_module --with-http_gunzip_module
make
make install
注:此處需要添加fastdfs-nginx-module的源碼
4.配置mod_fastdfs.conf
cp /root/fdfs/fastdfs-nginx-module-master/src/mod_fastdfs.conf /etc/fdfs/
mkdir /data/ngx
vi /etc/fdfs/mod_fastdfs.conf
修改下面四個參數:
# the base path to store log files
base_path=/data/ngx
# FastDFS tracker_server
tracker_server=:
# store_path#, based 0, if store_path0 not exists, it's value is base_path
# the paths must be exist
# must same as storage.conf
store_path0=/data/fdfs/storage
# if the url / uri including the group name
url_have_group_name = true
參見fastdfs 上傳成功,下載下傳400錯誤解決辦法
5.添加http.conf,mime.types到/etc/fdfs
cd /root/fdfs/fastdfs-/conf
cp http.conf mime.types /etc/fdfs
注:/root/fdfs/fastdfs-5.05為fastdfs的下載下傳解壓檔案目錄
參考Centos7 安裝FastDFS+nginx module
6.修改nginx配置檔案
vi /usr/local/nginx/conf/nginx.conf
配置内容如下:
location /group1/M00 {
#root指向資料根目錄,即storage的store_path
root /data/fdfs/storage/data;
ngx_fastdfs_module;
}
7.啟動nginx
啟動:
/usr/local/nginx/sbin/nginx
驗證:
檢視錯誤資訊
重新開機:
/usr/local/nginx/sbin/nginx -s reload
8.測試
成功下載下傳檔案到目前檔案夾