一、FastDFS的安裝(安裝FastDFS前需要安裝libevent和libfastcommon):
1、安裝libevent:
下載libevent-2.0.22-stable.tar.gz
下載地址:https://pan.baidu.com/s/1O6imihg2tE8D7zoMi8jlWw 提取碼: 7e95
下載后解壓縮 tar -zxvf libevent-2.0.22-stable.tar.gz
cd libevent-2.0.22-stable
./configure
make
sudo make install
2、安裝libfastcommon:
下載libfastcommon-master.zip
下載地址:https://pan.baidu.com/s/1IAtqmtgztR3ppEIIlSi7kA 提取碼: arvi
下載后解壓縮 unzip libfastcommon-master.zip
cd libfastcommon-master
./make.sh
sudo ./make.sh install
3、安裝FastDFS:
下載FastDFS_v5.08.tar.gz
下載地址:鏈接: https://pan.baidu.com/s/107hxJWxXkWF1rPOHIUCzWA 提取碼: 6ng2
下載后解壓縮 tar -zxvf FastDFS_v5.08.tar.gz
cd FastDFS
./make.sh
sudo ./make.sh install
二、配置FastDFS:
1、創建文件存儲目錄:
mkdir ~/data
mkdir ~/data/fastdfs
2、tracker配置:
創建tracker目錄:
mkdir ~/data/fastdfs/tracker
修改/etc/fdfs/tracker.conf配置文件
cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf
vim /etc/fdfs/tracker.conf
修改配置為:
# the base path to store data and log files
base_path=/home/{user}/data/fastdfs/tracker
3、storage配置:
創建storage目錄:
mkdir ~/data/fastdfs/storage
修改/etc/fdfs/storage.conf配置文件
cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf
vim /etc/fdfs/storage.conf
修改配置為:
# the base path to store data and log files
base_path=/home/{user}/data/fastdfs/storage
# store_path#, based 0, if store_path0 not exists, it's value is base_path
# the paths must be exist
store_path0=/home/{user}/data/fastdfs/storage
# tracker_server can ocur more than once, and tracker_server format is
# "host:port", host can be hostname or ip address
tracker_server=192.168.181.53:22122
4、client配置:
創建tracker目錄:
mkdir ~/data/fastdfs/client
修改/etc/fdfs/tracker.conf配置文件
cp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf
vim /etc/fdfs/client.conf
修改配置為:
# the base path to store log files
base_path=/home/{netsin}/data/fastdfs/client
# tracker_server can ocur more than once, and tracker_server format is
# "host:port", host can be hostname or ip address
tracker_server=192.168.181.53:22122
三、啟動和測試:
1、啟動服務:
#啟動tracker server
fdfs_trackerd /etc/fdfs/tracker.conf start
#啟動storage server
fdfs_storaged /etc/fdfs/storage.conf start
2、上傳測試:
/usr/bin/fdfs_upload_file /etc/fdfs/client.conf ./db.sqlite3
返回:group1/M00/00/00/wKi1NVyKBnCAQnsjAAAAAAAAAAA4572704
返回以下ID號,說明文件上傳成功。
四、安裝Nginx:
1、安裝fastdfs-nginx-module:
下載fastdfs-nginx-module_v1.16.tar.gz
下載地址:https://pan.baidu.com/s/11AEgSf1ZbSQGRaOBpTvqHQ 提取碼: zpqa
下載后解壓縮 tar -zxvf fastdfs-nginx-module_v1.16.tar.gz
2、安裝openssl:
下載openssl-1.1.0j.tar.gz
下載地址:鏈接: https://pan.baidu.com/s/1p341jCmAS_6z3JA_flrZyw 提取碼: fn18
下載后解壓縮 tar -zxvf openssl-1.1.0j.tar.gz
3、安裝zlib:
下載zlib-1.2.11.tar.gz
下載地址:https://pan.baidu.com/s/1d6B13reZGMRB3BmKzExwfw 提取碼: wiws
下載后解壓縮 tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make
sudo make install
4、安裝pcre:
下載pcre-8.35.tar.gz
下載地址:https://pan.baidu.com/s/1oz9QH1slDEOHG1hyoxeSbw 提取碼: us29
下載后解壓縮 tar -zxvf pcre-8.35.tar.gz
cd pcre-8.35
./configure
make
sudo make install
4、安裝nginx:
下載nginx-1.10.3.tar.gz
下載地址:https://pan.baidu.com/s/1hhuJdjE_GX4OUzPHHTBQFw 提取碼: fztp
下載后解壓縮 tar -zxvf nginx-1.10.3.tar.gz
cd nginx-1.10.3
./configure --prefix=/usr/local/nginx --with-openssl=/home/{user}/Desktop/FastDFS/openssl-1.1.0j --with-pcre=/home/{user}/Desktop/FastDFS/pcre-8.35 --with-zlib=/home/{user}/Desktop/FastDFS/zlib-1.2.11 --add-module=/home/{user}/Desktop/FastDFS/fastdfs-nginx-module/src
make
sudo make install
編譯錯誤處理:https://www.cnblogs.com/wanghaiqi24/p/10031989.html
5、配置Nginx:
修改配置文件:
sudo vim /usr/local/nginx/conf/nginx.conf
添加一下內容:
server{
listen 80;
server_name localhost;
location /group1/M00 {
alias /home/{user}/data/fastdfs/storage/data;
ngx_fastdfs_module;
}
6、配置mod_fastdfs:
復制配置文件:
sudo cp ./fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/mod_fastdfs.conf
修改配置文件:
# the base path to store log files
base_path=/home/netsin/data/fastdfs/storage
# FastDFS tracker_server can ocur more than once, and tracker_server format is
# "host:port", host can be hostname or ip address
# valid only when load_fdfs_parameters_from_tracker is true
tracker_server=192.168.181.53:22122
# store_path#, based 0, if store_path0 not exists, it's value is base_path
# the paths must be exist
# must same as storage.conf
store_path0=/home/netsin/data/fastdfs/storage
復制這兩個文件到fdfs配置文件,要不無法訪問nginx
cp ~/FastDFS/conf/http.conf /etc/fdfs/http.conf
cp ~/FastDFS/conf/mime.types /etc/fdfs/mime.types
7、啟動Nginx:
sudo /usr/local/nginx/sbin/nginx
8、通過Nginx下載文件:
wget http://192.168.181.53/group1/M00/00/00/wKi1NVyKJeKAU4puAAACGVfem5U8206.py
原文:https://blog.csdn.net/mhdp820121/article/details/88547526