一、安裝編譯環境
yum install gcc-c++
yum installopenssl-devel
yum install pcre-devel
yum install zlib-devel
二、安裝FastDFS
wget https://github.com/happyfish100/libfastcommon/archive/V1.0.7.tar.gz
tar -zxvfV1.0.7.tar.gz
cd libfastcommon-1.0.7
sh make.sh
sh make.sh install
ln -s/usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so
ln -s/usr/lib64/libfastcommon.so /usr/lib/libfastcommon.so
ln -s/usr/lib64/libfdfsclient.so /usr/local/lib/libfdfsclient.so
ln -s/usr/lib64/libfdfsclient.so /usr/lib/libfdfsclient.so
tar –zxvf FastDFS_v5.05.tar.gz
cd FastDFS
修改TARGET_PREFIX=$DESTDIR/usr/local
vi make.sh
sh make.sh
sh meke.sh install
vi /etc/fdfs/tracker.conf
base_path=/data/fastdfs
修改文件地址
vi /etc/fdfs/storage.conf
base_path=/data/fastdfs
store_path0=/data/images
創建文件存儲地址文件夾
mkdir /data/fastdfs
mkdir /data/images
mkdir /data/logs/
tracker_server=這裏是tracker地址
啓動tracker
/usr/local/bin/fdfs_trackerd/etc/fdfs/tracker.conf
啓動storage
/usr/local/bin/fdfs_storaged/etc/fdfs/storage.conf
測試上傳
/usr/bin/fdfs_test/etc/fdfs/client.conf /home/software/a.html
存儲服務監聽
/usr/local/bin/fdfs_monitor/etc/fdfs/storage.conf
netstat -unltp|grepfdfs
重啓服務
/usr/local/bin/restart.sh/usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf
/usr/local/bin/restart.sh/usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf
三、安裝Nginx和fastdfs-nginx-module
上傳nginx包
nginx-1.11.2.tar.gz
上傳nginx-fastdfs-module包
fastdfs-nginx-module_v1.15.tar.gz
2.解壓安裝包:
tar -zxvf nginx-1.11.2.tar.gz
tar -zxvf fastdfs-nginx-module_v1.15.tar.gz
3.進入nginx安裝包目錄之行以下命令
./configure--prefix=/usr/local/nginx --add-module=fastdfs-nginx-module/src
4.安裝Nginx:
make
make install
5.修改nginx.conf
vi /usr/local/nginx/conf/nginx.conf
80 server 添加如下:
location ~ /group[1-3]/M00{
alias /data/images/data;
ngx_fastdfs_module;
}
存儲文件添加軟鏈接
ln -s /data/images/data//data/images/data/M00
複製配置文件到/etc/fdfs
cp fastdfs-nginx-module/src/mod_fastdfs.conf/etc/fdfs/
vi /etc/fdfs/mod_fastdfs.conf
base_path=/data/fastdfs
tracker_server=ip:22122
store_path0=/data/images
啓動nginx
/usr/local/nginx/sbin/nginx –c /usr/local/nginx/conf/nginx.conf
修改客戶端配置
vi /etc/fdfs/client.conf
測試上傳
/usr/local/bin/fdfs_test/etc/fdfs/client.conf upload a.html
返回結果如下:表示成功
This is FastDFSclient test program v4.06
Copyright (C)2008, Happy Fish / YuQing
FastDFS may becopied only under the terms of the GNU General
Public License V3, which may be found inthe FastDFS source kit.
Please visitthe FastDFS Home Page http://www.csource.org/
for more detail.
[2016-09-06 17:20:37] DEBUG -base_path=/data/logs/fastdfs, connect_timeout=30, network_timeout=60,tracker_server_count=1, anti_steal_token=0, anti_steal_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=192.168.0.39, port=23000
group_name=group1, ip_addr=192.168.0.39,port=23000
storage_upload_by_filename
group_name=group1,remote_filename=M00/00/00/wKgAJ1fOimWAR3vOAAAABRsI9QY72.html
source ip address: 192.168.0.39
file timestamp=2016-09-06 17:20:37
file size=5
file crc32=453571846
file url:http://192.168.0.39:8080/group1/M00/00/00/wKgAJ1fOimWAR3vOAAAABRsI9QY72.html
storage_upload_slave_by_filename
group_name=group1,remote_filename=M00/00/00/wKgAJ1fOimWAR3vOAAAABRsI9QY72_big.html
source ip address: 192.168.0.39
file timestamp=2016-09-06 17:20:37
file size=5
file crc32=453571846
file url:http://192.168.0.39:8080/group1/M00/00/00/wKgAJ1fOimWAR3vOAAAABRsI9QY72_big.html