我是按照 XUDC寫的文章 在我虛擬機(jī)上裝的。我認(rèn)為fastdfs和nginx版本相差不要太大應(yīng)該是可以安裝的敦第,這篇文章流程都是按原文來的峰弹,我簡(jiǎn)略記錄下熟悉下畢竟還挺麻煩∥吖可以看原文
1.用到的壓縮包
安裝包名稱 | 下載地址 |
---|---|
libfastcommon | https://github.com/happyfish100/libfastcommon |
fastdfs-6.06.zip | https://github.com/happyfish100/fastdfs/releases |
fastdfs-nginx-module | https://github.com/happyfish100/fastdfs-nginx-module |
nginx (我安裝的時(shí)1.7.10) | http://nginx.org/download |
2.先安裝依賴
# 更新源
sudo apt-get update
# 安裝c++ 依賴庫(kù)
sudo apt-get install build-essential
sudo apt-get install libtool
# 安裝openssl 依賴 用于nginx
sudo apt-get install openssl
# 安裝pcre 依賴
sudo apt-get install libpcre3 libpcre3-dev
# 安裝zlib 依賴 當(dāng)時(shí)把1看成L nginx時(shí)會(huì)報(bào)錯(cuò)
sudo apt-get install zlib1g-dev
3.安裝FastDFS
3.1 安裝 libfastcommon
libfastcommon是一款從FastDFS項(xiàng)目中剝離出來的C基礎(chǔ)庫(kù)
# 解壓 libfastcommon-master.zip
unzip libfastcommon-master.zip
# 進(jìn)入 libfastcommon-master/
cd libfastcommon-master
# 執(zhí)行命令 如果報(bào)錯(cuò)的話可能是依賴沒裝好
./make.sh
./make.sh install
3.2 安裝 fastdfs
# 回到用戶主目錄鞠呈,解壓fastdfs-xx.zip
cd ..
unzip fastdfs-xx.zip
# 進(jìn)入解壓后的fastdfs-xx,執(zhí)行命令
cd fastdfs-xx
./make.sh install
3.3 配置tracker
# 復(fù)制tracker.conf.sample
sudo cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf
# 在 /home/username/ 目錄中創(chuàng)建目錄 fastdfs/tracker
mkdir -p /home/username/fastdfs/tracker
# 編輯/etc/fdfs/tracker.con配置文件
# 修改內(nèi)容
base_path = /home/xxx/fastdfs/tracker
3.4 配置存儲(chǔ)storage
# 復(fù)制storage.conf.sample
sudo cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf
# 在/home/xxx/fastdfs/ 目錄中創(chuàng)建storage目錄
mkdir -p /home/xxx/fastdfs/storage
# 編輯/etc/fdfs/storage.conf配置文件
base_path = /home/xxx/fastdfs/storage
tracker_server = 服務(wù)器ip:22122
3.5 啟動(dòng)tracker 和 storage
sudo /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start
sudo /usr/bin/fdfs_storaged /etc/fdfs/storage.conf start
# 啟動(dòng) 成功 的話會(huì)有
# fdfs_trackerd already running, pid: 11111
3.6 測(cè)試安裝狀態(tài)
sudo cp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf
# 編輯/etc/fdfs/client.conf配置文件 修改內(nèi)容
base_path = /home/xxx/fastdfs/tracker
tracker_server = ip:22122
# 上傳文件測(cè)試 /xx/xx.png為上傳的圖片
fdfs_upload_file /etc/fdfs/client.conf /xx/xx.png
# 返回字符串路徑表示成功
/group1/M00/00/00/wKgDb17S6NWAMK-UAACdyH9JNRs343.PNG
4.安裝Nginx并添加fastdfs模塊
# 回到用戶目錄右钾,解壓nginx-1.7.10.tar.gz
tar -zxvf nginx-1.7.10.tar.gz
# 解壓 fastdfs-nginx-module-master.zip
unzip fastdfs-nginx-module-master.zip
# 進(jìn)入nginx-1.7.10目錄
cd nginx-1.xx
# 執(zhí)行命令
./configure --prefix=/usr/local/nginx/ --add-module=/home/xx/fastdfs-nginx-module-master/src/
–add-module= 后邊是fastdfs-nginx-module-master解壓后的絕對(duì)路徑下的/src目錄
# 在nginx-1.xx目錄下執(zhí)行
make
make install
我這里是make命令報(bào)錯(cuò)蚁吝,最后查了下報(bào)錯(cuò)信息,然后修改了一個(gè)配置文件的代碼,注釋掉報(bào)錯(cuò)的代碼 又運(yùn)行了下
# 復(fù)制/mod_fastdfs.conf
sudo cp fastdfs-nginx-module-master/src/mod_fastdfs.conf /etc/fdfs/mod_fastdfs.conf
# 修改 /etc/fdfs/mod_fastdfs.conf
connect_timeout = 10
tracker_server = 服務(wù)器ip:22122
url_have_group_name = true
store_path0 = /home/xx/fastdfs/storage
# 復(fù)制http.conf
sudo cp fastdfs-6.xx/conf/http.conf /etc/fdfs/http.conf
# 復(fù)制mime.types
sudo cp fastdfs-6.xx/conf/mine.types /etc/fdfs/mime.types
# 修改Nginx配置
/usr/local/nginx/conf/nginx.conf
http server修改為以下
#user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location ~/group([0-9])/M00 {
ngx_fastdfs_module;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
# 啟動(dòng)nginx
sudo /usr/loacl/nginx/sbin/nginx
訪問下剛才的圖片: