項目環境是單節點,在同一group下,分項目目錄來存儲不同項目內容。
新建存儲目錄
mkdir -p /data/fastdfs/storage/hebi/data
然后編輯存儲文件
vim /etc/fdfs/storage.conf

修改內容解釋
store_path_count=2 #原值是1,這里表示開啟2給存儲點,多個存儲點寫相對數量。
store_path1=/data/fastdfs/storage/hebei/data #增加一個組,起始從0開始依次 往后填寫,例如第三個寫成store_path2={項目目錄絕對路徑}。
編輯 mod_fastdfs.conf
第一段

第二段 //去掉#號開啟組模式

修改內容解釋
store_pathh_count=2 #同上 store_path1=/data/fastdfs/storage/hebei/data #同上
在nginx主配置文件末尾添加虛擬機單獨目錄。
include /usr/local/nginx/vhost/*.conf;

在vhost創建fastdfs.conf
內容如下添加組信息。
server { server_name 192.168.1.185; listen 80; index index.html index.htm index.jsp; set $img_thumbnail_root /opt/fastdfs/thumb; set $img_file $img_thumbnail_root$uri; location ~.*\.(js|css)$ { expires 1h; } location ~* ^(\/(\w+)(\/M00)(.+\.(jpg|jpeg|gif|png))_(\d+)+x(\d+)+\.(jpg|jpeg|gif|png))$ { expires 30d; root $img_thumbnail_root; set $fdfs_group_root /data/fastdfs/storage/guilin/data; # 如果縮略圖不存在 if (!-f $img_file) { add_header X-Powered-By 'Nginx+Lua+GraphicsMagick By Yanue'; add_header file-path $request_filename; set $request_filepath $fdfs_group_root$4; set $img_width $6; set $img_height $7; set $img_ext $5; content_by_lua_file /usr/local/nginx/lua/cropSize.lua; } } location ~* ^(\/(\w+)(\/M01)(.+\.(jpg|jpeg|gif|png))_(\d+)+x(\d+)+\.(jpg|jpeg|gif|png))$ { expires 30d; root $img_thumbnail_root; set $fdfs_group_root /data/fastdfs/storage/hebei/data; # 如果縮略圖不存在 if (!-f $img_file) { add_header X-Powered-By 'Nginx+Lua+GraphicsMagick By Yanue'; add_header file-path $request_filename; set $request_filepath $fdfs_group_root$4; set $img_width $6; set $img_height $7; set $img_ext $5; content_by_lua_file /usr/local/nginx/lua/cropSize.lua; } } location /group1/M00 { alias /data/fastdfs/storage/guilin/data; ngx_fastdfs_module; } location /group1/M01 { alias /data/fastdfs/storage/hebei/data; ngx_fastdfs_module; } }
測試
同一張圖片不同的訪問路徑


