-
環境準備:
ubuntu16.0.04
nginx1.10.0
FastDFS5.08
-
jar包準備:
1)libfastCommonhttps://github.com/happyfish100/libfastcommon/tree/V1.0.36
2)fastDFShttps://github.com/happyfish100/fastdfs/tree/V5.11
3)nginxhttps://github.com/happyfish100/fastdfs/tree/V5.11
4)fastdfs-nginx-moudlehttps://github.com/happyfish100/fastdfs-nginx-module //將請求代理交給nginx管理
-
環境搭建
1)編譯安裝libfastCommon
./make.sh #編譯
./make.sh install # 安裝
ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so #創建符號鏈接
2)編譯安裝fastDFS
①配置tracker.conf
cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf
vim /etc/fdfs/tracker.conf 修改內容:存儲路徑 base_path=/ev/fdfs/tracker
②配置storage.conf
cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf
vim /etc/fdfs/storage.conf
修改內容:
base_path=/ev/fdfs/storage
tracker_server=39.108.254.46:22122
store_path0=/ev/fdfs/storage
③配置http.conf mine.types
cp fastdfs-5.11/conf/http.conf /etc/fdfs/
cp fastdfs-5.11/conf/mime.types /etc/fdfs/
④配置client.conf
cp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf
vim /etc/fdfs/client.conf
修改內容:
base_path=/tmp #存放日誌
tracker_server=39.108.254.46:22122
include http.conf #打開該行代碼 默認是註釋掉的
⑤安裝nginx
apt-get install libpcre3 libpcre3-dev zlib1g-dev openssl libssl-dev
tar -zxvf /home/ubuntu/source/nginx-1.10.0.tar.gz
cd /home/ubuntu/source/nginx
./configure --prefix=/usr/local/nginx --add-module=/usr/local/fastdfs-nginx-module/src/ # --prefix:安裝目錄;--add- module:fastdfs-nginx-module文件路徑
make && make install# 編譯 安裝
vi /usr/local/nginx/conf/nginx.conf #添加文件服務站點配置
添加內容如下
server {
listen 80;
server_name 39.108.254.46;
# 監聽域名中帶有group的,交給FastDFS模塊處理
location ~/group([0-9])/ {
ngx_fastdfs_module;
}
}
4啓動
啓動tracker:
/etc/init.d/fdfs_trackerd start
其他命令
/etc/init.d/fdfs_trackerd stop #停止
/etc/init.d/fdfs_trackerd restart #重啓
啓動storage
/etc/init.d/fdfs_storaged start
其他命令
/etc/init.d/fdfs_storaged stop #停止
/etc/init.d/fdfs_storaged restart #重啓
查看是否啓動
ps -aux|grep fdfs
測試fastDFS安裝情況
fdfs_test /etc/fdfs/client.conf upload /tmp/1.png
會出現這麼一段
FastDFS may be copied only under the terms of the GNU General
Public License V3, which may be found in the FastDFS source kit.
Please visit the FastDFS Home Page http://www.csource.org/
for more detail.
[2019-07-22 09:23:21] DEBUG - base_path=/tmp, connect_timeout=30, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_stea
l_secret_key length=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s, use_storage_id=0, storage server id count: 0
tracker_query_storage_store_list_without_group:
server 1. group_name=, ip_addr=39.108.254.46, port=23000
group_name=group1, ip_addr=39.108.254.46, port=23000
storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/rBImEV01EAuAFhByAAWP9PXRiN0289.png
source ip address: 172.18.38.17
file timestamp=2019-07-22 09:23:23
file size=364532
file crc32=4124149981
example file url: http://39.108.254.46/group1/M00/00/00/rBImEV01EAuAFhByAAWP9PXRiN0289.png
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/rBImEV01EAuAFhByAAWP9PXRiN0289_big.png
source ip address: 172.18.38.17
file timestamp=2019-07-22 09:23:25
file size=364532
file crc32=4124149981
example file url: http://xx.xx/group1/M00/00/00/rBImEV01EAuAFhByAAWP9PXRiN0289_big.png
啓動nginx:
cd /usr/local/nginx/sbin/
./nginx
/usr/local/nginx/sbin/nginx -s stop #停止
/usr/local/nginx/sbin/nginx -s reload #重新加載配置文件
啓動成功後有這麼一段
root@iZwz97wxeq8a2n8v9yneogZ:/usr/local/nginx/sbin# ./nginx
ngx_http_fastdfs_set pid=4840
然後測試剛纔測試上傳的圖片
http://xx.xx/group1/M00/00/00/rBImEV01EAuAFhByAAWP9PXRiN0289_big.png
tracker端口:22122
storage端口:23000
naginx 80
安裝過程中,可修改自己安裝位置,但一定要記住安裝在哪