1、上传需要的安装包
[root@test-10 src]
/usr/local/src
[root@test-10 src]
-rw-r--r-- 1 root root 336939 Mar 25 15:08 fastdfs-5.11.tar.gz
-rw-r--r-- 1 root root 17494 Mar 25 15:08 fastdfs_client_java_v1.10.tar.gz
-rw-r--r-- 1 root root 17510 Mar 25 15:08 fastdfs-nginx-module_v1.16.tar.gz
-rw-r--r-- 1 root root 478888 Mar 25 15:08 libfastcommon-1.0.36.zip
-rw-r--r-- 1 root root 1039530 Mar 25 15:10 nginx-1.18.0.tar.gz
2、安装依赖
[root@test-10 src]

3、安装libfastcommon
[root@test-10 ~]
[root@test-10 src]
[root@test-10 src]
[root@test-10 src]
[root@test-10 libfastcommon-1.0.36]
total 36
drwxr-xr-x 2 root root 4096 Apr 5 2017 doc
-rw-r--r-- 1 root root 8005 Apr 5 2017 HISTORY
-rw-r--r-- 1 root root 566 Apr 5 2017 INSTALL
-rw-r--r-- 1 root root 1606 Apr 5 2017 libfastcommon.spec
-rwxr-xr-x 1 root root 3099 Apr 5 2017 make.sh
drwxr-xr-x 2 root root 4096 Apr 5 2017 php-fastcommon
-rw-r--r-- 1 root root 2763 Apr 5 2017 README
drwxr-xr-x 3 root root 4096 Mar 25 15:15 src
[root@test-10 libfastcommon-1.0.36]
.....
[root@test-10 libfastcommon-1.0.36]
.....
4、安装Fastdfs
[root@test-10 src]
/usr/local/src
[root@test-10 src]
total 1856
-rw-r--r-- 1 root root 336939 Mar 25 15:08 fastdfs-5.11.tar.gz
-rw-r--r-- 1 root root 17494 Mar 25 15:08 fastdfs_client_java_v1.10.tar.gz
-rw-r--r-- 1 root root 17510 Mar 25 15:08 fastdfs-nginx-module_v1.16.tar.gz
-rw-r--r-- 1 root root 478888 Mar 25 15:08 libfastcommon-1.0.36.zip
-rw-r--r-- 1 root root 1039530 Mar 25 15:10 nginx-1.18.0.tar.gz
[root@test-10 src]
[root@test-10 local]
[root@test-10 fastdfs-5.11]
total 136
drwxrwxr-x 3 root root 4096 Jun 3 2017 client
drwxrwxr-x 2 root root 4096 Jun 3 2017 common
drwxrwxr-x 2 root root 4096 Jun 3 2017 conf
-rw-rw-r-- 1 root root 35067 Jun 3 2017 COPYING-3_0.txt
-rw-rw-r-- 1 root root 3171 Jun 3 2017 fastdfs.spec
-rw-rw-r-- 1 root root 33100 Jun 3 2017 HISTORY
drwxrwxr-x 2 root root 4096 Jun 3 2017 init.d
-rw-rw-r-- 1 root root 7755 Jun 3 2017 INSTALL
-rwxrwxr-x 1 root root 5548 Jun 3 2017 make.sh
drwxrwxr-x 2 root root 4096 Jun 3 2017 php_client
-rw-rw-r-- 1 root root 2380 Jun 3 2017 README.md
-rwxrwxr-x 1 root root 1768 Jun 3 2017 restart.sh
-rwxrwxr-x 1 root root 1680 Jun 3 2017 stop.sh
drwxrwxr-x 4 root root 4096 Jun 3 2017 storage
drwxrwxr-x 2 root root 4096 Jun 3 2017 test
drwxrwxr-x 2 root root 4096 Jun 3 2017 tracker
[root@test-10 fastdfs-5.11]
.....
[root@test-10 fastdfs-5.11]
.....
[root@test-10 fastdfs-5.11]
5、配置并启动tracker
[root@test-10 fdfs]
[root@test-10 fdfs]
[root@test-10 fdfs]
[root@test-10 ~]
base_path=/opt/fastdfs/tracker
http.server_port=80
[root@test-10 ~]
[root@test-10 ~]
tcp 0 0 0.0.0.0:22122 0.0.0.0:* LISTEN 26814/fdfs_trackerd
6、配置并启动storage
[root@test-10 ~]
base_path=/opt/fastdfs/storage
store_path0=/opt/fastdfs/fdfs_storage
tracker_server=10.110.10.110:22122
http.server_port=80
[root@test-10 ~]
[root@test-10 ~]
tcp 0 0 0.0.0.0:23000 0.0.0.0:* LISTEN 28779/fdfs_storaged
[root@test-10 fastdfs]
00 07 0E 15 1C 23 2A 31 38 3F 46 4D 54 5B 62 69 70 77 7E 85 8C 93 9A A1 A8 AF B6 BD C4 CB D2 D9 E0 E7 EE F5 FC
01 08 0F 16 1D 24 2B 32 39 40 47 4E 55 5C 63 6A 71 78 7F 86 8D 94 9B A2 A9 B0 B7 BE C5 CC D3 DA E1 E8 EF F6 FD
02 09 10 17 1E 25 2C 33 3A 41 48 4F 56 5D 64 6B 72 79 80 87 8E 95 9C A3 AA B1 B8 BF C6 CD D4 DB E2 E9 F0 F7 FE
03 0A 11 18 1F 26 2D 34 3B 42 49 50 57 5E 65 6C 73 7A 81 88 8F 96 9D A4 AB B2 B9 C0 C7 CE D5 DC E3 EA F1 F8 FF
04 0B 12 19 20 27 2E 35 3C 43 4A 51 58 5F 66 6D 74 7B 82 89 90 97 9E A5 AC B3 BA C1 C8 CF D6 DD E4 EB F2 F9
05 0C 13 1A 21 28 2F 36 3D 44 4B 52 59 60 67 6E 75 7C 83 8A 91 98 9F A6 AD B4 BB C2 C9 D0 D7 DE E5 EC F3 FA
06 0D 14 1B 22 29 30 37 3E 45 4C 53 5A 61 68 6F 76 7D 84 8B 92 99 A0 A7 AE B5 BC C3 CA D1 D8 DF E6 ED F4 FB
7、上传测试
[root@test-10 fastdfs]
base_path=/opt/fastdfs
tracker_server=10.110.10.110:22122
[root@test-10 fastdfs]
group_name=group1, remote_filename=M00/00/00/Ct0BJ2BcWYOAcviMAABdrZgsqUU032.jpg
example file url: http://10.110.10.110/group1/M00/00/00/Ct0BJ2BcWYOAcviMAABdrZgsqUU032_big.jpg
8、Nginx整合
[root@test-10 ~]
[root@test-10 src]
total 1856
-rw-r--r-- 1 root root 336939 Mar 25 15:08 fastdfs-5.11.tar.gz
-rw-r--r-- 1 root root 17494 Mar 25 15:08 fastdfs_client_java_v1.10.tar.gz
-rw-r--r-- 1 root root 17510 Mar 25 15:08 fastdfs-nginx-module_v1.16.tar.gz
-rw-r--r-- 1 root root 478888 Mar 25 15:08 libfastcommon-1.0.36.zip
-rw-r--r-- 1 root root 1039530 Mar 25 15:10 nginx-1.18.0.tar.gz
[root@test-10 src]
[root@test-10 local]
[root@test-10 fastdfs-nginx-module]
total 12
-rw-rw-r-- 1 500 500 2342 May 4 2014 HISTORY
-rw-rw-r-- 1 500 500 1733 May 4 2014 INSTALL
drwxrwxr-x 2 500 500 4096 May 4 2014 src
[root@test-10 nginx-1.18.0]
CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"
CORE_LIBS="$CORE_LIBS -L/usr/lib -lfastcommon -lfdfsclient"
[root@test-10 fastdfs-nginx-module]
[root@test-10 fastdfs-nginx-module]
base_path=/opt/fastdfs
tracker_server=10.110.10.110:22122
url_have_group_name = true
store_path0=/opt/fastdfs/fdfs_storage
[root@test-10 ~]
[root@test-10 ~]
[root@test-10 ~]
[root@test-10 ~]
[root@test-10 ~]
[root@test-10 ~]
[root@test-10 src]
[root@test-10 src]
[root@test-10 nginx-1.18.0]
.....
[root@test-10 nginx-1.18.0]
.....
[root@test-10 nginx-1.18.0]
.....
[root@test-10 nginx-1.18.0]
total 16
drwxr-xr-x 2 root root 4096 Mar 26 09:55 conf
drwxr-xr-x 2 root root 4096 Mar 26 09:55 html
drwxr-xr-x 2 root root 4096 Mar 26 09:55 sbin
[root@test-10 conf]
worker_processes auto;
error_log logs/error.log info;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
sendfile on;
keepalive_timeout 65;
gzip on;
server {
listen 80;
server_name localhost;
location /group1/M00/ {
root /opt/fastdfs/fdfs_storage/data;
ngx_fastdfs_module;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
[root@test-10 conf]
9、访问之前测试上传返回的url路径,查看图片是否存在

10、常见故障
1、上传图片正常,在浏览器里面无法访问,现象是页面一直在加载无任何报错显示,检查nginx error日志,发现如下报错:
[2022-02-24 11:28:52] ERROR - file: shared_func.c, line: 974, stat /etc/fdfs/mod_fastdfs.conf fail, errno: 13, error info: Permission denied
[2022-02-24 11:28:52] ERROR - file: /usr/local/fastdfs-nginx-module/src/common.c, line: 155, load conf file "/etc/fdfs/mod_fastdfs.conf" fail, ret code: 13
解决办法:vim nginx.conf
user root;