[root@host-192-168-0-249 ~]# cd /opt
[root@host-192-168-0-249 opt]# mkdir fastdfs-server
[root@host-192-168-0-249 fastdfs-server]# wget https://github.com/happyfish100/libfastcommon/archive/refs/tags/V1.0.59.zip
[root@host-192-168-0-249 fastdfs-server]# unzip V1.0.59.zip
[root@host-192-168-0-249 fastdfs-server]# cd libfastcommon-1.0.59/
[root@host-192-168-0-249 libfastcommon-1.0.59]# ./make.sh
[root@host-192-168-0-249 libfastcommon-1.0.59]# ./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
[root@host-192-168-0-249 libfastcommon-1.0.59]# cd /opt/fastdfs-server/
[root@host-192-168-0-249 libfastcommon-1.0.59]# wget https://github.com/happyfish100/fastdfs/archive/refs/tags/V6.08.zip
[root@host-192-168-0-249 fastdfs-server]# unzip V6.08.zip
[root@host-192-168-0-249 fastdfs-6.08]# cd fastdfs-6.08/
[root@host-192-168-0-249 fastdfs-6.08]# ./make.sh
[root@host-192-168-0-249 fastdfs-6.08]# ./make.sh install
# ln -s /usr/bin/fdfs_trackerd /usr/local/bin
# ln -s /usr/bin/fdfs_storaged /usr/local/bin
# ln -s /usr/bin/stop.sh /usr/local/bin
# ln -s /usr/bin/restart.sh /usr/local/bin
[root@host-192-168-0-249 fdfs]# cd /etc/fdfs/
[root@host-192-168-0-249 fdfs]# ll
总用量 96
-rw-r--r-- 1 root root 23981 8月 15 13:33 anti-steal.jpg
-rw-r--r-- 1 root root 1915 8月 15 11:37 client.conf
-rw-r--r-- 1 root root 965 8月 15 13:33 http.conf
-rw-r--r-- 1 root root 31172 8月 15 13:33 mime.types
-rw-r--r-- 1 root root 3737 8月 15 13:31 mod_fastdfs.conf
-rw-r--r-- 1 root root 10256 8月 15 11:34 storage.conf
-rw-r--r-- 1 root root 620 8月 15 11:17 storage_ids.conf
-rw-r--r-- 1 root root 9145 8月 15 11:21 tracker.conf
[root@host-192-168-0-249 fdfs]# vi tracker.conf
# is this config file disabled
# false for enabled
# true for disabled
disabled = false
# the tracker server port
port = 22122
# the base path to store data and log files
base_path = /opt/fastdfs-server/tracker
# HTTP port on this tracker server
http.server_port = 8888
创建目录
[root@host-192-168-0-249 fdfs]# mkdir -p /opt/fastdfs-server/tracker
关闭防火墙
[root@host-192-168-0-249 fdfs]# systemctl stop firewalld.service
启动tracker服务
[root@host-192-168-0-249 fdfs]# systemctl start fdfs_trackerd.service
[root@host-192-168-0-249 fdfs]# netstat -anp | grep fdfs
tcp 0 0 0.0.0.0:22122 0.0.0.0:* LISTEN 53024/fdfs_trackerd
[root@host-192-168-0-249 fastdfs-server]# mkdir -p /opt/fastdfs-server/storage
[root@host-192-168-0-249 fdfs]# cd /etc/fdfs/
[root@host-192-168-0-249 fdfs]# ll
总用量 96
-rw-r--r-- 1 root root 23981 8月 15 13:33 anti-steal.jpg
-rw-r--r-- 1 root root 1915 8月 15 11:37 client.conf
-rw-r--r-- 1 root root 965 8月 15 13:33 http.conf
-rw-r--r-- 1 root root 31172 8月 15 13:33 mime.types
-rw-r--r-- 1 root root 3737 8月 15 13:31 mod_fastdfs.conf
-rw-r--r-- 1 root root 10256 8月 15 11:34 storage.conf
-rw-r--r-- 1 root root 620 8月 15 11:17 storage_ids.conf
-rw-r--r-- 1 root root 9145 8月 15 16:59 tracker.conf
[root@host-192-168-0-249 fdfs]# vi storage.conf
# the base path to store data and log files
# NOTE: the binlog files maybe are large, make sure
# the base path has enough disk space,
# eg. the disk free space should > 50GB
base_path = /opt/fastdfs-server/storage
# store_path#, based on 0, to configure the store paths to store files
# if store_path0 not exists, it's value is base_path (NOT recommended)
# the paths must be exist.
#
# IMPORTANT NOTE:
# the store paths' order is very important, don't mess up!!!
# the base_path should be independent (different) of the store paths
store_path0 = /opt/fastdfs-server/storage
# tracker_server can ocur more than once for multi tracker servers.
# the value format of tracker_server is "HOST:PORT",
# the HOST can be hostname or ip address,
# and the HOST can be dual IPs or hostnames seperated by comma,
# the dual IPS must be an inner (intranet) IP and an outer (extranet) IP,
# or two different types of inner (intranet) IPs.
# for example: 192.168.2.100,122.244.141.46:22122
# another eg.: 192.168.1.10,172.17.4.21:22122
tracker_server = 192.168.0.249:22122
tracker_server = 192.168.0.249:22122
# the port of the web server on this storage server
http.server_port = 8888
启动服务
[root@host-192-168-0-249 fdfs]# systemctl start fdfs_storaged.service
[root@host-192-168-0-249 opt]# cd /opt/
wget https://nginx.org/download/nginx-1.23.1.tar.gz
[root@host-192-168-0-249 opt]# tar xvf nginx-1.23.1.tar.gz
[root@host-192-168-0-249 opt]# wget https://github.com/happyfish100/fastdfs-nginx-module/archive/refs/tags/V1.22.zip
[root@host-192-168-0-249 opt]# unzip V1.22.zip
[root@host-192-168-0-249 opt]# cd nginx-1.23.1/
[root@host-192-168-0-249 nginx-1.23.1]# ./configure --add-module=/opt//opt/fastdfs-nginx-module-1.22/src
[root@host-192-168-0-249 nginx-1.23.1]# make -j 10 && make install
查看版本
[root@host-192-168-0-249 nginx-1.23.1]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.23.1
built by gcc 8.4.1 20200928 (UOS 8.4.1-1) (GCC)
[root@host-192-168-0-249 opt]# cd fastdfs-nginx-module-1.22/src/
[root@host-192-168-0-249 src]# cp mod_fastdfs.conf /etc/fdfs/
[root@host-192-168-0-249 src]# vi /etc/fdfs/mod_fastdfs.conf
# 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.0.249:22122
# the port of the local storage server
# the default value is 23000
storage_server_port=23000
# if the url / uri including the group name
# set to false when uri like /M00/00/00/xxx
# set to true when uri like ${group_name}/M00/00/00/xxx, such as group1/M00/xxx
# default value is false
url_have_group_name = true
# 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=/opt/fastdfs-server/storage
[root@host-192-168-0-249 src]# vi /usr/local/nginx/conf/nginx.conf
server {
listen 8888;
server_name localhost;
在server 里面添加如下内容
location /group1/M00 {
alias /opt/fastdfs-server/storage/data;
autoindex on;
ngx_fastdfs_module;
}
}
启动nginx
[root@host-192-168-0-249 src]# /usr/local/nginx/sbin/nginx
修改tracker客户端配置文件
[root@host-192-168-0-249 src]# cd /etc/fdfs/
[root@host-192-168-0-249 fdfs]# ll
总用量 96
-rw-r--r-- 1 root root 23981 8月 15 13:33 anti-steal.jpg
-rw-r--r-- 1 root root 1915 8月 15 11:37 client.conf
-rw-r--r-- 1 root root 965 8月 15 13:33 http.conf
-rw-r--r-- 1 root root 31172 8月 15 13:33 mime.types
-rw-r--r-- 1 root root 3737 8月 15 13:31 mod_fastdfs.conf
-rw-r--r-- 1 root root 10256 8月 15 11:34 storage.conf
-rw-r--r-- 1 root root 620 8月 15 11:17 storage_ids.conf
-rw-r--r-- 1 root root 9145 8月 15 16:59 tracker.conf
[root@host-192-168-0-249 fdfs]# vi client.conf
# the base path to store log files
base_path = /opt/fastdfs-server/client
# tracker_server can ocur more than once for multi tracker servers.
# the value format of tracker_server is "HOST:PORT",
# the HOST can be hostname or ip address,
# and the HOST can be dual IPs or hostnames seperated by comma,
# the dual IPS must be an inner (intranet) IP and an outer (extranet) IP,
# or two different types of inner (intranet) IPs.
# for example: 192.168.2.100,122.244.141.46:22122
# another eg.: 192.168.1.10,172.17.4.21:22122
tracker_server = 192.168.0.249:22122
tracker_server = 192.168.0.249:22122
[root@host-192-168-0-249 fastdfs-server]# cd /opt/fastdfs-server/
[root@host-192-168-0-249 fastdfs-server]# ll
总用量 4700
-rw-r--r-- 1 root root 1885674 8月 15 13:43 1.jpg
-rw-r--r-- 1 root root 1631019 8月 15 16:29 2.jpg
drwxr-xr-x 2 root root 19 8月 15 11:40 client
drwxr-xr-x 13 root root 322 3月 3 10:46 fastdfs-6.08
drwxr-xr-x 3 root root 47 11月 19 2019 fastdfs-nginx-module
drwxr-xr-x 6 root root 199 8月 15 11:13 libfastcommon-1.0.59
drwxr-xr-x 4 root root 30 8月 15 11:34 storage
drwxr-xr-x 4 root root 30 8月 15 11:23 tracker
-rw-r--r-- 1 root root 348138 8月 15 11:09 V1.0.59.zip
-rw-r--r-- 1 root root 22297 8月 15 11:45 V1.22.zip
-rw-r--r-- 1 root root 913521 8月 15 11:14 V6.08.zip
上传文件命令:
[root@host-192-168-0-249 fastdfs-server]# /usr/bin/fdfs_upload_file /etc/fdfs/client.conf 2.jpg
group1/M00/00/00/wKgA-WL7LFSAcXFIABjjK0nS-NU415.jpg
将/opt/fastdfs-server/2.jpg上传
在浏览器输入:192.168.0.249:8888/group1/M00/00/00/wKgA-WL7LI-AZ5WeABjKOnS-NU507.jpg