一擂送、準(zhǔn)備安裝包
libfastcommon:FastDFS分離出的一些公用函數(shù)包
FastDFS:FastFDS本體
fastdfs-nginx-module:FastFDS和nignx的關(guān)聯(lián)模塊
nginx:發(fā)布訪問服務(wù)
二计露、安裝
0.將安裝包上傳至/home/software/fastdfs
1.安裝基礎(chǔ)環(huán)境
? ? yum install -y gcc gcc-c++
? ? yum -y install libevent
2.安裝libfastcommon函數(shù)庫(kù)
? ?解壓: tar? -zxvf libfastcommon-1.0.42.tar.gz
? ? 進(jìn)入到libfastcommon文件夾:./make.sh
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ./make.sh install
3.安裝fastdfs主程序文件
? ? 解壓:tar -zxvf? fastdfs-6.04.tar.gz
? ? 進(jìn)入fastdfs目錄:./make.sh
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ./make.sh install
4.確保文件夾存在
? ? ? ? /usr/bin:包含了可執(zhí)行文件
? ? ? ? /etc/fdfs:包含了配置文件
5.拷貝配置文件 cp /home/software/FastDFS/fastdfs-6.04/conf/*? ? ?/etc/fdfs/
三、配置tracker
????1.配置tracker配置文件??
? ? ? ? ? ? cd /etc/fdfs
? ? ? ? ? ? ?vim tracker.conf
????2.修改基礎(chǔ)路徑
? ? ? ? ? ? base_path=/usr/local/fastdfs/tracker
? ? ? ? ? ? ?mkdir? /usr/local/fastdfs/tracker
????3.啟動(dòng)tracker服務(wù)??
? ? ? ? ? ? /usr/bin/fdfs_trackerd? ?/etc/fdfs/tracker.conf
? ? 4.查看進(jìn)程? ?ps -ef|grep tracker
? ? 5.停止tracker
? ? ? ? ? ? /usr/bin/stop.sh? /etc/fdfs/tracker.conf
四流妻、配置storage
????1.配置storage配置文件??
? ? ? ? ? ? cd /etc/fdfs
? ? ? ? ? ? ?vim storage.conf
? ? ? ?#修改組名
????????group_name=imooc
????????# 修改storage的工作空間
????????base_path=/usr/local/fastdfs/storage
????????# 修改storage的存儲(chǔ)空間
????????store_path0=/usr/local/fastdfs/storage
????????# 修改tracker的地址和端口號(hào),用于心跳
????????tracker_server=192.168.1.153:22122
????????# 后續(xù)結(jié)合nginx的一個(gè)對(duì)外服務(wù)端口號(hào)
????????http.server_port=8888
? ? 2.創(chuàng)建目錄? mkdir??/usr/local/fastdfs/storage -p
? ? 3.啟動(dòng)storage(前提:必須先啟動(dòng)tracker)? ?/usr/bin/fdfs_storaged /etc/fdfs/storage.conf
? ? 4.查看進(jìn)程:?ps -ef|grep storage
五、測(cè)試圖片上傳
0.創(chuàng)建/usr/local/fastdfs/client后氢橙,配置/etc/fdfs/client.conf
? ? ?base_path=/usr/local/fastdfs/client
? ? ?tracker_server=192.168.1.153:22122
1.上傳測(cè)試圖片至/home/logo.png
2.確保先啟動(dòng)tracker,再啟動(dòng)storage
? ? /usr/bin/fdfs_test? ? /etc/fdfs/client.conf? ?upload? /home/logo.png
六恬偷、配置Nginx FastDFS實(shí)現(xiàn)文件服務(wù)器(按步驟來配置)
fastdfs安裝好以后是無法通過http訪問的悍手,這個(gè)時(shí)候就需要借助nginx,所以需要安裝fastdfs第三方模塊到nginx中袍患,就能使用了坦康。
注:nginx需要和storage在同一個(gè)節(jié)點(diǎn)
1.安裝nginx插件
????解壓nginx的fastdfs壓縮包:tar -zxvf fastdfs-nginx-module-1.22.tar.gz
????復(fù)制配置文件:cp mod_fastdfs.conf? /etc/fdfs
????修改/fastdfs-nginx-modules/src/config文件,主要是修改路徑诡延,把local刪除滞欠,因?yàn)閒astdfs安裝的時(shí)候我們沒有修改路徑
2.安裝nginx,詳情參考http://www.reibang.com/p/65b48c4a6606
????其中配置模塊肆良,增加fastdfs插件
./configure --prefix=/usr/local/nginx --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-http_gzip_static_module --http-client-body-temp-path=/var/temp/nginx/client --http-proxy-temp-path=/var/temp/nginx/proxy --http-fastcgi-temp-path=/var/temp/nginx/fastcgi --http-uwsgi-temp-path=/var/temp/nginx/uwsgi --http-scgi-temp-path=/var/temp/nginx/scgi --add-module=/home/software/fastdfs/fastdfs-nginx-module-1.22/src
????修改nginx.conf筛璧,添加如下虛擬機(jī)
3.修改mod_fastdfs.conf配置文件
????創(chuàng)建文件夾:?mkdir /usr/local/fastdfs/tmp
4.啟動(dòng)nginx
5.訪問? Ip+代理轉(zhuǎn)發(fā)端口+storage存儲(chǔ)組名
http://192.168.31.221:8888/imooc/M00/00/00/wKgf3V-eChSAdlnFAALdsLCF3uA337.JPG