目录

fastdfs安装

安装环境说明

安装libfastcommon

yum install gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel wget -y
wget https://github.com/happyfish100/libfastcommon/archive/refs/tags/V1.0.56.tar.gz
tar -xzvf V1.0.56.tar.gz 
cd libfastcommon-1.0.56
./make.sh ./make.sh install

安装fastdfs

wget https://github.com/happyfish100/fastdfs/archive/refs/tags/V6.08.tar.gz
tar -xzvf V6.08.tar.gz 
cd fastdfs-6.08
./make.sh
./make.sh install
vim /etc/fdfs/tracker.conf
      
# tracker的基础路径
base_path=/opt/app/fastdfs/tracker
# 程序启动的用户组
run_by_group=fastdfs
# 程序启动的用户
run_by_user = fastdfs
# 创建上边配置的 base_path
mkdir -p /opt/app/fastdfs/tracker
vim /etc/fdfs/storage.conf 

# storage的基础路径
base_path = /opt/app/fastdfs/storage
# storage的数据存储路径
store_path0 = /opt/app/fastdfs/storage
# tracker的地址
tracker_server = 172.20.197.145:22122
# 程序启动的用户组
run_by_group = fastdfs
# 程序启动的用户
run_by_user = fastdfs
# http端口
http.server_port = 8888
# 创建上边配置的 base_path
mkdir -p /opt/app/fastdfs/storage
cp fastdfs-6.08/conf/http.conf /etc/fdfs/
cp fastdfs-6.08/conf/mime.types /etc/fdfs/
vim /usr/lib/systemd/system/fdfs_storaged.service

PIDFile=/opt/app/fastdfs/storage/data/fdfs_storaged.pid
vim /usr/lib/systemd/system/fdfs_trackerd.service

PIDFile=/opt/app/fastdfs/tracker/data/fdfs_trackerd.pid

安装带有fastdfs-nginx-module模块的nginx

- 下载安装包

wget http://nginx.org/download/nginx-1.20.1.tar.gz

wget https://github.com/vozlt/nginx-module-vts/archive/v0.1.12.tar.gz
tar -xzvf nginx-1.20.1.tar.gz
tar -xzvf v0.1.12.tar.gz
mv fastdfs-nginx-module-1.22 nginx-1.20.1
cd nginx-1.20.1

# nginx添加模块fastdfs-nginx-module
./configure --add-module=fastdfs-nginx-module-1.22/src
cp fastdfs-nginx-module-1.22/mod_fastdfs.conf /etc/fdfs/
vim /etc/fdfs/mod_fastdfs.conf

tracker_server=172.20.197.145:22122
store_path0=/opt/app/fastdfs/storage
url_have_group_name = true
make && make install

配置nginx并启动

vim /usr/local/nginx/conf/nginx.conf
server {
        listen       8888;	// 与之前的配置http.server_port一致
        server_name  localhost;

        location ^~ /group {	
             ngx_fastdfs_module;
        }
}
/usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
/usr/local/nginx/sbin/nginx

测试

vim /etc/fdfs/client.conf 

base_path = /opt/app//fastdfs/client
tracker_server = 172.20.197.145:22122
mkdir -p /opt/app//fastdfs/client
/usr/bin/fdfs_upload_file /etc/fdfs/client.conf  1.jpeg 
group1/M00/00/00/rBTFkWIy1JmAasUaAAKdgKIZ2IU87.jpeg