Linux下安装fastdfs

FastDFS安装
1、从GitHub下载FastDFS安装包

访问GitHub的这个仓库https://github.com/happyfish100里面有FastDfs对应的安装包,其中这里要下载的3个安装包分别是
fastdfs.zip -------------------- FastDfsbao
libfastcommon.zip ----------- FastDfs的公共依赖包
fastdfs-nginx-module.zip ---- FastDfs与nginx模块

1.1、下载fastdfs.zip包

wget https://codeload.github.com/happyfish100/libfastcommon/zip/master -O fastdfs.zip

[root@ecs-s6-medium-2-linux-20191122095023 fastdfs]#
[root@ecs-s6-medium-2-linux-20191122095023 fastdfs]# wget https://codeload.github.com/happyfish100/libfastcommon/zip/master -O fastdfs.zip
--2019-11-25 14:34:15--  https://codeload.github.com/happyfish100/libfastcommon/zip/master
Resolving codeload.github.com... 13.229.189.0
Connecting to codeload.github.com|13.229.189.0|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 218600 (213K) [application/zip]
Saving to: “fastdfs.zip”

100%[=====================================================================================================================================================================>] 218,600     79.4K/s   in 2.7s

2019-11-25 14:34:19 (79.4 KB/s) - “fastdfs.zip” saved [218600/218600]

[root@ecs-s6-medium-2-linux-20191122095023 fastdfs]#
[root@ecs-s6-medium-2-linux-20191122095023 fastdfs]#
1.2、下载libfastcommon.zip包

wget https://github.com/happyfish100/libfastcommon/archive/master.zip -O libfastcommon.zip

[root@ecs-s6-medium-2-linux-20191122095023 fastdfs]# wget https://github.com/happyfish100/libfastcommon/archive/master.zip -O libfastcommon.zip
--2019-11-26 10:10:49--  https://github.com/happyfish100/libfastcommon/archive/master.zip
Resolving github.com... 52.74.223.119
Connecting to github.com|52.74.223.119|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://codeload.github.com/happyfish100/libfastcommon/zip/master [following]
--2019-11-26 10:10:50--  https://codeload.github.com/happyfish100/libfastcommon/zip/master
Resolving codeload.github.com... 13.250.162.133
Connecting to codeload.github.com|13.250.162.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 218600 (213K) [application/zip]
Saving to: “libfastcommon.zip”

100%[=====================================================================================================================================================================>] 218,600      375K/s   in 0.6s

2019-11-26 10:10:51 (375 KB/s) - “libfastcommon.zip” saved [218600/218600]

[root@ecs-s6-medium-2-linux-20191122095023 fastdfs]#
1.3、下载fastdfs-nginx-module.zip包

wget https://github.com/happyfish100/fastdfs-nginx-module/archive/master.zip -O fastdfs-nginx-module.zip

[root@ecs-s6-medium-2-linux-20191122095023 fastdfs]# wget https://github.com/happyfish100/fastdfs-nginx-module/archive/master.zip -O fastdfs-nginx-module.zip
--2019-11-26 10:44:47--  https://github.com/happyfish100/fastdfs-nginx-module/archive/master.zip
Resolving github.com... 52.74.223.119
Connecting to github.com|52.74.223.119|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://codeload.github.com/happyfish100/fastdfs-nginx-module/zip/master [following]
--2019-11-26 10:44:47--  https://codeload.github.com/happyfish100/fastdfs-nginx-module/zip/master
Resolving codeload.github.com... 13.229.189.0
Connecting to codeload.github.com|13.229.189.0|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/zip]
Saving to: “fastdfs-nginx-module.zip”

    [ <=>                                                                                                                                                                  ] 22,333      --.-K/s   in 0.09s

2019-11-26 10:44:48 (238 KB/s) - “fastdfs-nginx-module.zip” saved [22333]

1.4、解压
-rw-r--r-- 1 root root 900840 Nov 26 10:27 fastdfs.zip
-rw-r--r-- 1 root root 218600 Nov 26 10:27 libfastcommon.zip
[root@ecs-s6-medium-2-linux-20191122095023 fastdfs]#
[root@ecs-s6-medium-2-linux-20191122095023 fastdfs]#
[root@ecs-s6-medium-2-linux-20191122095023 fastdfs]# unzip fastdfs-nginx-module.zip
[root@ecs-s6-medium-2-linux-20191122095023 fastdfs]# unzip fastdfs.zip
[root@ecs-s6-medium-2-linux-20191122095023 fastdfs]# unzip libfastcommon.zip
...
[root@ecs-s6-medium-2-linux-20191122095023 fastdfs]# ll
total 1132
drwxr-xr-x 12 root root   4096 Nov 23 10:07 fastdfs-master
drwxr-xr-x  3 root root   4096 Nov 19 12:29 fastdfs-nginx-module-master
-rw-r--r--  1 root root  22333 Nov 26 10:44 fastdfs-nginx-module.zip
-rw-r--r--  1 root root 900840 Nov 26 10:27 fastdfs.zip
drwxr-xr-x  5 root root   4096 Nov 23 10:03 libfastcommon-master
-rw-r--r--  1 root root 218600 Nov 26 10:27 libfastcommon.zip
[root@ecs-s6-medium-2-linux-20191122095023 fastdfs]#
2、编译及安装

注意:在操作下面的步骤前先安装对应的插件
请运行下面命令:

yum install gcc
yum install gcc-c++
yum install perl

2.1、编译

编译libfastcommon模块,到libfastcommon-master目录下先运行./make.sh 在运行./make.sh install

[root@ecs-s6-medium-2-linux-20191122095023 fastdfs]# cd libfastcommon-master/
[root@ecs-s6-medium-2-linux-20191122095023 libfastcommon-master]# ll
total 40
drwxr-xr-x 2 root root 4096 Nov 23 10:03 doc
-rw-r--r-- 1 root root 9945 Nov 23 10:03 HISTORY
-rw-r--r-- 1 root root  669 Nov 23 10:03 INSTALL
-rw-r--r-- 1 root root 1607 Nov 23 10:03 libfastcommon.spec
-rwxr-xr-x 1 root root 3253 Nov 23 10:03 make.sh
drwxr-xr-x 2 root root 4096 Nov 23 10:03 php-fastcommon
-rw-r--r-- 1 root root 2776 Nov 23 10:03 README
drwxr-xr-x 3 root root 4096 Nov 23 10:03 src
[root@ecs-s6-medium-2-linux-20191122095023 libfastcommon-master]#
[root@ecs-s6-medium-2-linux-20191122095023 libfastcommon-master]#
[root@ecs-s6-medium-2-linux-20191122095023 libfastcommon-master]# ./make.sh
...
[root@ecs-s6-medium-2-linux-20191122095023 libfastcommon-master]# ./make.sh install
mkdir -p /usr/lib64
mkdir -p /usr/lib
mkdir -p /usr/include/fastcommon
install -m 755 libfastcommon.so /usr/lib64
install -m 644 common_define.h hash.h chain.h logger.h base64.h shared_func.h pthread_func.h ini_file_reader.h _os_define.h sockopt.h sched_thread.h http_func.h md5.h local_ip_func.h avl_tree.h ioevent.h ioevent_loop.h fast_task_queue.h fast_timer.h process_ctrl.h fast_mblock.h connection_pool.h fast_mpool.h fast_allocator.h fast_buffer.h skiplist.h multi_skiplist.h flat_skiplist.h skiplist_common.h system_info.h fast_blocked_queue.h php7_ext_wrapper.h id_generator.h char_converter.h char_convert_loader.h common_blocked_queue.h multi_socket_client.h skiplist_set.h fc_list.h json_parser.h /usr/include/fastcommon
if [ ! -e /usr/lib/libfastcommon.so ]; then ln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.so; fi
[root@ecs-s6-medium-2-linux-20191122095023 libfastcommon-master]#

编译 fastdfs包,到fastdfs-master目录下先运行./make.sh在运行./make.sh install

[root@ecs-s6-medium-2-linux-20191122095023 libfastcommon-master]# cd ../
[root@ecs-s6-medium-2-linux-20191122095023 fastdfs]# ll
total 1132
drwxr-xr-x 12 root root   4096 Nov 23 10:07 fastdfs-master
drwxr-xr-x  3 root root   4096 Nov 19 12:29 fastdfs-nginx-module-master
-rw-r--r--  1 root root  22333 Nov 26 10:44 fastdfs-nginx-module.zip
-rw-r--r--  1 root root 900840 Nov 26 10:27 fastdfs.zip
drwxr-xr-x  5 root root   4096 Nov 26 10:59 libfastcommon-master
-rw-r--r--  1 root root 218600 Nov 26 10:27 libfastcommon.zip
[root@ecs-s6-medium-2-linux-20191122095023 fastdfs]#
[root@ecs-s6-medium-2-linux-20191122095023 fastdfs]# cd fastdfs-master/
[root@ecs-s6-medium-2-linux-20191122095023 fastdfs-master]# ll
total 156
drwxr-xr-x 3 root root  4096 Nov 23 10:07 client
drwxr-xr-x 2 root root  4096 Nov 23 10:07 common
drwxr-xr-x 2 root root  4096 Nov 23 10:07 conf
-rw-r--r-- 1 root root 35067 Nov 23 10:07 COPYING-3_0.txt
drwxr-xr-x 4 root root  4096 Nov 23 10:07 docker
-rw-r--r-- 1 root root  3170 Nov 23 10:07 fastdfs.spec
-rw-r--r-- 1 root root 35383 Nov 23 10:07 HISTORY
drwxr-xr-x 2 root root  4096 Nov 23 10:07 images
drwxr-xr-x 2 root root  4096 Nov 23 10:07 init.d
-rw-r--r-- 1 root root  8344 Nov 23 10:07 INSTALL
-rwxr-xr-x 1 root root  5517 Nov 23 10:07 make.sh
drwxr-xr-x 2 root root  4096 Nov 23 10:07 php_client
-rw-r--r-- 1 root root  2448 Nov 23 10:07 README.md
-rw-r--r-- 1 root root  1700 Nov 23 10:07 README_zh.md
-rwxr-xr-x 1 root root  1768 Nov 23 10:07 restart.sh
-rwxr-xr-x 1 root root   763 Nov 23 10:07 setup.sh
-rwxr-xr-x 1 root root  1680 Nov 23 10:07 stop.sh
drwxr-xr-x 4 root root  4096 Nov 23 10:07 storage
drwxr-xr-x 2 root root  4096 Nov 23 10:07 test
drwxr-xr-x 2 root root  4096 Nov 23 10:07 tracker
[root@ecs-s6-medium-2-linux-20191122095023 fastdfs-master]# ./make.sh
...
[root@ecs-s6-medium-2-linux-20191122095023 fastdfs-master]# ./make.sh install
mkdir -p /usr/bin
mkdir -p /etc/fdfs
cp -f fdfs_trackerd /usr/bin
if [ ! -f /etc/fdfs/tracker.conf.sample ]; then cp -f ../conf/tracker.conf /etc/fdfs/tracker.conf.sample; fi
if [ ! -f /etc/fdfs/storage_ids.conf.sample ]; then cp -f ../conf/storage_ids.conf /etc/fdfs/storage_ids.conf.sample; fi
mkdir -p /usr/bin
mkdir -p /etc/fdfs
cp -f fdfs_storaged  /usr/bin
if [ ! -f /etc/fdfs/storage.conf.sample ]; then cp -f ../conf/storage.conf /etc/fdfs/storage.conf.sample; fi
mkdir -p /usr/bin
mkdir -p /etc/fdfs
mkdir -p /usr/lib64
mkdir -p /usr/lib
cp -f fdfs_monitor fdfs_test fdfs_test1 fdfs_crc32 fdfs_upload_file fdfs_download_file fdfs_delete_file fdfs_file_info fdfs_appender_test fdfs_appender_test1 fdfs_append_file fdfs_upload_appender fdfs_regenerate_filename /usr/bin
if [ 0 -eq 1 ]; then cp -f libfdfsclient.a /usr/lib64; cp -f libfdfsclient.a /usr/lib/;fi
if [ 1 -eq 1 ]; then cp -f libfdfsclient.so /usr/lib64; cp -f libfdfsclient.so /usr/lib/;fi
mkdir -p /usr/include/fastdfs
cp -f ../common/fdfs_define.h ../common/fdfs_global.h ../common/mime_file_parser.h ../common/fdfs_http_shared.h ../tracker/tracker_types.h ../tracker/tracker_proto.h ../tracker/fdfs_shared_func.h ../tracker/fdfs_server_id_func.h ../storage/trunk_mgr/trunk_shared.h tracker_client.h storage_client.h storage_client1.h client_func.h client_global.h fdfs_client.h /usr/include/fastdfs
if [ ! -f /etc/fdfs/client.conf.sample ]; then cp -f ../conf/client.conf /etc/fdfs/client.conf.sample; fi
[root@ecs-s6-medium-2-linux-20191122095023 fastdfs-master]#

3、配置
3.1、将fastdfs-master目录下的conf文件夹下的所有文件复制到/etc/fdfs目录下
[root@ecs-s6-medium-2-linux-20191122095023 fastdfs]# ll
total 1132
drwxr-xr-x 12 root root   4096 Nov 23 10:07 fastdfs-master
drwxr-xr-x  3 root root   4096 Nov 19 12:29 fastdfs-nginx-module-master
-rw-r--r--  1 root root  22333 Nov 26 10:44 fastdfs-nginx-module.zip
-rw-r--r--  1 root root 900840 Nov 26 10:27 fastdfs.zip
drwxr-xr-x  5 root root   4096 Nov 26 11:02 libfastcommon-master
-rw-r--r--  1 root root 218600 Nov 26 10:27 libfastcommon.zip
[root@ecs-s6-medium-2-linux-20191122095023 fastdfs]#
[root@ecs-s6-medium-2-linux-20191122095023 fastdfs]#
[root@ecs-s6-medium-2-linux-20191122095023 fastdfs]# cp fastdfs-master/c
client/ common/ conf/
[root@ecs-s6-medium-2-linux-20191122095023 fastdfs]# cp fastdfs-master/conf/* /etc/fdfs
[root@ecs-s6-medium-2-linux-20191122095023 fastdfs]#
[root@ecs-s6-medium-2-linux-20191122095023 fastdfs]# cd /etc/fdfs
[root@ecs-s6-medium-2-linux-20191122095023 fdfs]# ll
total 116
-rw-r--r-- 1 root root 23981 Nov 26 11:14 anti-steal.jpg
-rw-r--r-- 1 root root  1834 Nov 26 11:14 client.conf
-rw-r--r-- 1 root root  1834 Nov 25 14:44 client.conf.sample
-rw-r--r-- 1 root root   955 Nov 26 11:14 http.conf
-rw-r--r-- 1 root root 31172 Nov 26 11:14 mime.types
-rw-r--r-- 1 root root  9479 Nov 26 11:14 storage.conf
-rw-r--r-- 1 root root  9479 Nov 25 14:44 storage.conf.sample
-rw-r--r-- 1 root root   527 Nov 26 11:14 storage_ids.conf
-rw-r--r-- 1 root root   527 Nov 25 14:44 storage_ids.conf.sample
-rw-r--r-- 1 root root  7818 Nov 26 11:14 tracker.conf
-rw-r--r-- 1 root root  7818 Nov 25 14:44 tracker.conf.sample
[root@ecs-s6-medium-2-linux-20191122095023 fdfs]#
3.2、更改配置文件

这里需要更改tracker.conf、storage.conf、storage_ids.conf、client.conf这三个配置文件的内容
更改tracker.conf配置文件

1、打开tracker.conf找到 base_path=/home/yuqing/fastdfs 这个配置项吧路径改为,你要设置存放fastdfs信息的路径,这个路径必须存在。我这里为 /home/fastdfs/tracker

更改storage.conf配置文件

1、打开storage.conf找到 base_path=/home/yuqing/fastdfs 这个配置项吧路径改为,你要设置存储节点保存上传文件的跟路径,这个路径必须存在。我这里为/home/fastdfs/storage/group1/storage
2、找到 store_path0=/home/yuqing/fastdfs 这个配置项吧这个路径设置为,你要设置存储节点具体保存文件的路径,这个路径必须存在。我这里为/home/fastdfs/storage/group1/storage0
3、找到 tracker_server=192.168.209.121:22122 这个配置项吧ip改为追踪节点的ip

更改storage_ids.conf配置

打开storage_ids.conf文件将对应的ip设为存储节点的ip

更改配置

1、打开tracker.conf找到 base_path=/home/yuqing/fastdfs 这个配置项吧路径改为,你要设置存放fastdfs信息的根路径,这个路径必须存在。我这里为 /home/fastdfs/tracker
找到 tracker_server=192.168.209.121:22122 这个配置项吧ip改为追踪节点的ip

4、启动服务及验证上传
4.1、启动服务

当配置好配置文件后输入service fdfs_trackerd start 命令启动追踪服务,输入service fdfs_storaged start启动存储节点服务具体操作如下:

[root@ecs-s6-medium-2-linux-20191122095023 fdfs]#
[root@ecs-s6-medium-2-linux-20191122095023 fdfs]# service fdfs_trackerd start
Starting FastDFS tracker server:
[root@ecs-s6-medium-2-linux-20191122095023 fdfs]#
[root@ecs-s6-medium-2-linux-20191122095023 fdfs]# service fdfs_storaged start
Starting FastDFS storage server:
[root@ecs-s6-medium-2-linux-20191122095023 fdfs]# ps -ef | grep fdfs
root      2464  2846  0 11:44 pts/0    00:00:00 grep fdfs
root      2954     1  0 Nov25 ?        00:00:03 /usr/bin/fdfs_trackerd /home/fastdfs/tracker/tracker.conf
root      3017     1  0 Nov25 ?        00:00:02 /usr/bin/fdfs_storaged /home/fastdfs/tracker/storage.conf
[root@ecs-s6-medium-2-linux-20191122095023 fdfs]#
[root@ecs-s6-medium-2-linux-20191122095023 fdfs]#
[root@ecs-s6-medium-2-linux-20191122095023 fdfs]#

4.2、上传图片验证

输入 /usr/bin/fdfs_test /etc/fdfs/client.conf upload /etc/fdfs/anti-steal.jpg 命令如果输出下面的信息说明图片上传成功

[root@ecs-s6-medium-2-linux-20191122095023 fdfs]#
[root@ecs-s6-medium-2-linux-20191122095023 fdfs]#  /usr/bin/fdfs_test /etc/fdfs/client.conf upload /etc/fdfs/anti-steal.jpg
This is FastDFS client test program v6.03

Copyright (C) 2008, Happy Fish / YuQing

FastDFS may be copied only under the terms of the GNU General
Public License V3, which may be found in the FastDFS source kit.
Please visit the FastDFS Home Page http://www.fastken.com/
for more detail.

[2019-11-26 13:30:11] DEBUG - base_path=/home/fastdfs/tracker, connect_timeout=10, network_timeout=60, tracker_server_count=2, 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.81, port=23000

group_name=group1, ip_addr=192.168.0.81, port=23000
storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/wKgAUV3cuGOAe6SSAABdreSfEnY372.jpg
source ip address: 192.168.0.81
file timestamp=2019-11-26 13:30:11
file size=23981
file crc32=3835630198
example file url: http://192.168.0.81/group1/M00/00/00/wKgAUV3cuGOAe6SSAABdreSfEnY372.jpg
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/wKgAUV3cuGOAe6SSAABdreSfEnY372_big.jpg
[2019-11-26 13:30:14] ERROR - file: connection_pool.c, line: 142, connect to server 192.168.0.197:22122 fail, errno: 113, error info: No route to host
source ip address: 192.168.0.81
file timestamp=2019-11-26 13:30:11
file size=23981
file crc32=3835630198
example file url: http://192.168.0.81/group1/M00/00/00/wKgAUV3cuGOAe6SSAABdreSfEnY372_big.jpg
[root@ecs-s6-medium-2-linux-20191122095023 fdfs]#
4.3、设置fastdfs开机自启

修改/etc/rc.d/rc.local 文件,在后面添加service fdfs_trackerd start 和
service fdfs_storaged start

[root@ecs-s6-medium-2-linux-20191122095023 fdfs]#
[root@ecs-s6-medium-2-linux-20191122095023 fdfs]# vim /etc/rc.d/rc.local
[root@ecs-s6-medium-2-linux-20191122095023 fdfs]# cat /etc/rc.d/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
service fdfs_trackerd start
service fdfs_storaged start
[root@ecs-s6-medium-2-linux-20191122095023 fdfs]#
5、安装fastdfs-nginx-module

注意:安装nginx前需安装对应的依赖库
请执行如下命令:

yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel

5.1、下载nginx并解压安装
[root@localhost nginx]#
[root@localhost nginx]# pwd
/usr/local/nginx
[root@localhost nginx]# wget http://nginx.org/download/nginx-1.16.1.tar.gz
--2019-11-27 18:23:08--  http://nginx.org/download/nginx-1.16.1.tar.gz
正在解析主机 nginx.org (nginx.org)... 62.210.92.35, 95.211.80.227, 2001:1af8:4060:a004:21::e3
正在连接 nginx.org (nginx.org)|62.210.92.35|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1032630 (1008K) [application/octet-stream]
正在保存至: “nginx-1.16.1.tar.gz.1”

100%[=====================================================================================================================================================================>] 1,032,630   7.69KB/s 用时 91s

2019-11-27 18:24:39 (11.1 KB/s) - 已保存 “nginx-1.16.1.tar.gz.1” [1032630/1032630])

[root@localhost nginx]#
[root@localhost nginx]# tar -zxvf nginx*.gz
。。。
[root@localhost nginx]# ll
总用量 1016
drwxr-xr-x.  8 1001 1001     158 8月  13 20:51 nginx-1.16.1
-rw-r--r--.  1 root root 1032630 8月  14 01:01 nginx-1.16.1.tar.gz
[root@localhost nginx]#
[root@localhost nginx]# cd nginx-1.16.1
[root@localhost nginx-1.16.1]# ./configure --prefix=/usr/local/nginx/nginx-1.16.1 --add-module=/usr/local/fastdfs/fastdfs-nginx-module-master/src/
[root@localhost nginx-1.16.1]#
[root@localhost nginx-1.16.1]# make
。。。
[root@localhost nginx-1.16.1]# make install
。。。
[root@localhost nginx-1.16.1]# ll
总用量 756
drwxr-xr-x. 6 1001 1001   4096 11月 27 18:25 auto
-rw-r--r--. 1 1001 1001 296463 8月  13 20:51 CHANGES
-rw-r--r--. 1 1001 1001 452171 8月  13 20:51 CHANGES.ru
drwxr-xr-x. 2 1001 1001    168 11月 27 18:25 conf
-rwxr-xr-x. 1 1001 1001   2502 8月  13 20:51 configure
drwxr-xr-x. 4 1001 1001     72 11月 27 18:25 contrib
drwxr-xr-x. 2 1001 1001     40 11月 27 18:25 html
-rw-r--r--. 1 1001 1001   1397 8月  13 20:51 LICENSE
-rw-r--r--. 1 root root    428 11月 27 18:28 Makefile
drwxr-xr-x. 2 1001 1001     21 11月 27 18:25 man
drwxr-xr-x. 4 root root    187 11月 27 18:30 objs
-rw-r--r--. 1 1001 1001     49 8月  13 20:51 README
drwxr-xr-x. 2 root root     19 11月 27 18:30 sbin
drwxr-xr-x. 9 1001 1001     91 11月 27 18:25 src
5.2、更改配置文件

修改nginx配置文件
进入conf文件夹在nginx.conf文件的http{}大括号中添加下面内容

	server {
		listen 8888;
		server_name localhost;
		location ~ /(safe|group|g|s)([0-9]+)/M00 {
			ngx_fastdfs_module;
		}
		error_page 500 502 503 504 /50x.html;
	
		location = /50x.html {
			root html;
		}
	}

将/usr/local/fastdfs/fastfs-nginx-module/src/mod_fastdfs.conf文件复制到/etc/fdfs目录下并更改里面的内容

[root@localhost nginx-1.16.1]# cp /usr/local/fastdfs/fastdfs-nginx-module-master/src/mod_fastdfs.conf /etc/fdfs

更改 mod_fastdfs.conf 配置文件的内容,具体改动如下

#启用分组匹配
url_have_group_name = true
#更改追踪服务的的地址
tracker_server=192.168.80.131:22122
#更改存在数据路径更 storage.conf 配置文件中的 store_path0 一样即可
store_path0=/home/fastdfs/storage/group1/storage0
5.3、上传图片与认证
[root@localhost nginx-1.16.1]# /usr/bin/fdfs_test /etc/fdfs/client.conf upload /etc/fdfs/anti-steal.jpg
This is FastDFS client test program v6.03

Copyright (C) 2008, Happy Fish / YuQing

FastDFS may be copied only under the terms of the GNU General
Public License V3, which may be found in the FastDFS source kit.
Please visit the FastDFS Home Page http://www.fastken.com/
for more detail.

[2019-11-27 18:53:54] DEBUG - base_path=/home/fastdfs/tracker, connect_timeout=10, 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.80.131, port=23000

group_name=group1, ip_addr=192.168.80.131, port=23000
storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/wKhQg13eVcKAI_p6AABdreSfEnY856.jpg
source ip address: 192.168.80.131
file timestamp=2019-11-27 18:53:54
file size=23981
file crc32=3835630198
example file url: http://192.168.80.131/group1/M00/00/00/wKhQg13eVcKAI_p6AABdreSfEnY856.jpg
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/wKhQg13eVcKAI_p6AABdreSfEnY856_big.jpg
source ip address: 192.168.80.131
file timestamp=2019-11-27 18:53:54
file size=23981
file crc32=3835630198
example file url: http://192.168.80.131/group1/M00/00/00/wKhQg13eVcKAI_p6AABdreSfEnY856_big.jpg
[root@localhost nginx-1.16.1]#
[root@localhost nginx-1.16.1]#
[root@localhost nginx-1.16.1]#
[root@localhost nginx-1.16.1]# wget http://192.168.80.131:8888/group1/M00/00/00/wKhQg13eVcKAI_p6AABdreSfEnY856_big.jpg
--2019-11-27 18:54:45--  http://192.168.80.131:8888/group1/M00/00/00/wKhQg13eVcKAI_p6AABdreSfEnY856_big.jpg
正在连接 192.168.80.131:8888... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:23981 (23K) [image/jpeg]
正在保存至: “wKhQg13eVcKAI_p6AABdreSfEnY856_big.jpg”

100%[=====================================================================================================================================================================>] 23,981      --.-K/s 用时 0s

2019-11-27 18:54:45 (703 MB/s) - 已保存 “wKhQg13eVcKAI_p6AABdreSfEnY856_big.jpg” [23981/23981])

[root@localhost nginx-1.16.1]#

注意:wget 的url需要加上nginx代理的端口号即8888

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值