首先把需要的壓縮文件上傳到linux服務器中
安裝依賴:
????yum -y install gcc
????yum install -y unzip zip??
????yum -y install libevent??
????yum -y install pcre pcre-devel zlib zlib-devel openssl openssl-devel
安裝libfastcommon-master?
? ? 解壓壓縮包:unzip libfastcommon-master.zip
????進入到libfastcommon-master文件下:cd libfastcommon-master
????安裝編譯:
? ? ? ? ./make.sh? ?
?????????./make.sh install?
安裝FastDFS_v5.08
????解壓FastDFS_v5.08:tar xvf FastDFS_v5.08.tar.gz
? ? 進入到FastDFS文件下:cd FastDFS
? ? 編譯安裝:./make.sh && ./make.sh install
? ??安裝完成麻诀,我們應該能在/etc/init.d/目錄,通過命令ll /etc/init.d/ | grep fdfs看到FastDFS提供的啟動腳本:
????????????????fdfs_trackerd 是tracker啟動腳本
????????????????fdfs_storaged 是storage啟動腳本
????我們可以在 /etc/fdfs目錄,通過命令查看到以下配置文件模板:ll /etc/fdfs
? ??????????????tarcker.conf.sample 是tracker的配置文件模板
????????????????storage.conf.sample 是storage的配置文件模板
????????????????client.conf.sample 是客戶端的配置文件模板
? ? 啟動tracker
? ??????編輯tracker配置
? ??????????cp tracker.conf.sample tracker.conf
? ??????????vim tracker.conf
? ??????????打開tracker.conf界阁,修改base_path配置:base_path=/xuepa/fdfs/tracker # tracker的數(shù)據(jù)和日志存放目錄
? ?????????剛剛配置的目錄可能不存在摩瞎,我們創(chuàng)建出來:?mkdir -p /xuepa/fdfs/tracker
? ????????啟動tracker:我們可以使用 sh /etc/init.d/fdfs_trackerd 啟動乱灵,不過安裝過程中硫朦,fdfs已經(jīng)被設置為系統(tǒng)服務,我們可以采用熟悉的服務啟動方式:service fdfs_trackerd start
????啟動Storage?
? ??????編輯storage配置:
????????????cp storage.conf.sample storage.conf
? ??????????vim storage.conf
? ? ? ? ? ? 打開storage.conf侵俗,修改base_path配置:
? ??????????????base_path=/xuepa/fdfs/storage # storage的數(shù)據(jù)和日志存放目錄
????????????????store_path0=/xuepa/fdfs/storage # storage的上傳文件存放路徑
????????????????tracker_server=IP地址:22122 # tracker的地址
? ??????剛剛配置的目錄可能不存在锨用,我們創(chuàng)建出來:mkdir -p /xuepa/fdfs/storage
? ??????啟動storage:我們可以使用 sh /etc/init.d/fdfs_storaged 啟動,同樣我們可以用服務啟動方式
? ??????????????service fdfs_storaged start # 啟動fdfs_storaged服務隘谣,停止用stop
查看fdfs是否啟動:
啟動fdfs的客戶端進行檢測:? ?
? ? 配置fdfs客戶端:
????????cp client.conf.sample client.conf
? ??????vim client.conf
? ??????????base_path=/tmp
? ??????????tracker_server=47.101.189.41:22122
? ? 運行客戶端進行上傳測試:/usr/bin/fdfs_upload_file /etc/fdfs/client.conf /tmp/1.jpeg? 返回上傳成功文件的id
安裝FastDFS的nginx模塊
? ? 解壓壓縮包:tar xvf fastdfs-nginx-module_v1.16.tar.gz
? ? 進入到src文件下:cd fastdfs-nginx-module/src/
? ? 修改配置文件:vim config
? ??????????# 執(zhí)行下面命令(將配置中的/usr/local改為/usr)::%s+/usr/local/+/usr/+g
? ? ?將src目錄下的mod_fastdfs.conf復制到 /etc/fdfs目錄:cp mod_fastdfs.conf? /etc/fdfs/
? ? ?編輯該文件:vim /etc/fdfs/mod_fastdfs.cof
? ? ??修改一下配置:
? ??????????connect_timeout=10 # 客戶端訪問文件連接超時時長(單位:秒)
????????????tracker_server=192.168.1.250:22122? # tracker服務IP和端口
????????????url_have_group_name=true? ? ? ? ? ? # 訪問鏈接前綴加上組名
????????????store_path0=/xuepa/fdfs/storage? ? ? ? # 文件存儲路徑
進入到/home/xuepa/fdfs/FastDFS/conf文件下找到http.conf文件:cd /home/xuepa/fdfs/FastDFS/conf/
把http.conf復制到/etc/fdfs文件下:cp http.conf mime.types /etc/fdfs/
nginx已經(jīng)在服務器內(nèi)安裝過了增拥,但是現(xiàn)在需要nginx和FastDFS整合
進入到nginx的安裝目錄:cd /home/xuepa/nginx-1.10.0
重新配置nginx :./configure --prefix=/opt/nginx --sbin-path=/usr/bin/nginx --add-module=/home/xuepa/fdfs/fastdfs-nginx-module/src
只做編譯不做安裝:make
備份之前的nginx啟動:mv /usr/bin/nginx? /usr/bin/nginx-bck
用編譯玩的nginx替換之前的nginx:cp? ? /home/leyou/nginx-1.10.0/objs/nginx? ? /usr/bin/
完成之后去修改nginx的配置:
server {
? ? ? ? listen? ? ? 80;
? ? ? ? server_name? image.xuepa.com;
? ? # 監(jiān)聽域名中帶有group的,交給FastDFS模塊處理
? ? ? ? location ~/group([0-9])/ {
? ? ? ? ? ? ngx_fastdfs_module;
? ? ? ? }
? ? ? ? location / {
? ? ? ? ? ? root? html;
? ? ? ? ? ? index? index.html index.htm;
? ? ? ? }
? ? ? ? error_page? 500 502 503 504? /50x.html;
? ? ? ? location = /50x.html {
? ? ? ? ? ? root? html;
? ? ? ? }
? ? }