1.首先安裝解壓各個壓縮包(略過)
2.然后安裝完統一編譯安裝各個依賴(略過)
3.開始安裝nginx
./configure --add-module=/opt/fastdfs-nginx-module/src/ #整合了fatdfs的模塊 make make install
ps:根據自己的情況修改模塊的地址。
安裝完nginx后,會出現幾行字,這是nginx的安裝后所在的目錄
4.修改nginx.conf
nginx.conf 的更改 user root 避免權限的問題 location /group1/M00 { #url映射 root /mnt/xfsd/fastdfs/storage/data; #指向的目錄 ngx_fastdfs_module; #調用的模塊 }
5.修改 fastdfs-nignx模塊的配置文件 mod_fastdfs.conf
bash_path tracker_server= #與tracker 的地址要相同 url_have_group_name= #可選 ,是否訪問資源帶上組名 group_name store_path0= #和store服務的store_path0需要相同 把mod_fastdfs.conf cope到/etc/fdfs/下
6.將mod_fastdfs.conf 復制到/etc/fdfs/下
cp mod_fastdfs.conf /etc/fdfs/
7.修改storage.conf
http.server_port=80 #端口號和nginx的一致
8.之前修改nginx.conf中建立了url的映射,現在要把映射的地址建立軟連接到storage的data目錄
ln -s /mnt/xfsd/fastdfs/storage/data /mnt/xfsd/fastdfs/storage/data/M00
9.開始使用nginx
/usr/local/nginx/sbin/nginx #啟動nginx
10.上傳文件測試
/usr/bin/fdfs_test /etc/fdfs/client.conf upload 上傳文件的地址
11.通過文件的地址就可以在瀏覽器中訪問到了
有可能會報錯:
***[2017-03-23 16:50:14] ERROR - file: ini_file_reader.c, line: 631, include file "http.conf" not exists, line: "#include http.conf"
[2017-03-23 16:50:14] ERROR - file: /opt/fastdfs-nginx-module/src/common.c, line: 155, load conf file "/etc/fdfs/mod_fastdfs.conf" fail, ret code: 2
2017/03/23 16:50:14 [alert] 16970#0: worker process 18289 exited with fatal code 2 and cannot be respawned
這個是由於缺少 http.conf
在nginx/conf/目錄下有 http.conf , 把它復制到 fastdfs-nginx-module/src/ 目錄下。重新編譯並安裝nginx。
****
[2017-03-23 16:29:26] DEBUG - file: storage_service.c, line: 3384, client ip: 119.29.154.224, storage server id: 10.104.99.138
[2017-03-23 16:30:01] ERROR - file: trunk_mgr/trunk_client.c, line: 108, no trunk server
[2017-03-23 16:30:03] ERROR - file: storage_service.c, line: 8069, client ip: 119.29.154.224, unkown cmd: 79
# if use a trunk file to store several small files # default value is false # since V3.00 use_trunk_file = false #改為false 將不會使用 trunk server