blog:linux:fastdfs_install

fastdfs安装

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
  • 下载安装包
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
  • 修改配置文件(配置文件默认在 /etc/fdfs/ 下)
    • 修改tracker.conf
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
  • 修改storage.conf
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
  • 将以下两个文件拷贝到fastdfs的配置目录下,方便后续fastdfs-nginx-module的使用
cp fastdfs-6.08/conf/http.conf /etc/fdfs/
cp fastdfs-6.08/conf/mime.types /etc/fdfs/
  • 默认服务启动的时候会寻找pid文件。pid文件默认是 /opt/fastcfs/data/fdfstrackerd.pid 和 /opt/fastcfs/data/fdfsstoraged.pid。 不修改的话会报错
    • 修改/usr/lib/systemd/system/fdfsstoraged.service和/usr/lib/systemd/system/fdfstrackerd.service文件,调整PIDFile
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

- 下载安装包

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的默认安装目录在 /usr/local/nginx
vim /usr/local/nginx/conf/nginx.conf
server {
        listen       8888;	// 与之前的配置http.server_port一致
        server_name  localhost;

        location ^~ /group {	
             ngx_fastdfs_module;
        }
}
  • 检查nginx的配置
/usr/local/nginx/sbin/nginx -t
  • 如果出现以下内容,则证明nginx的配置通过校验
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
  • 启动nginx
/usr/local/nginx/sbin/nginx
  • 调整 /etc/fdfs/client.conf 的配置
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
  • 通过nginx访问图片
    • 在浏览器中输入地址访问 (http://XXX.XXX.XXX.XXX:XXXX/group1/M00/00/00/rBTFkWIy1JmAasUaAAKdgKIZ2IU87.jpeg),如果能正常展示图片,则证明配置成功
  • blog/linux/fastdfs_install.txt
  • 最后更改: 2022/03/17 07:02
  • okami