fastdfs

[root@yfm03 ~]# cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)

[root@yfm03 data]# nginx -v
nginx version: nginx/1.16.1

[root@yfm03 fdfs]# nginx -V
nginx version: nginx/1.16.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) 
built with OpenSSL 1.1.1c FIPS  28 May 2019 (running with OpenSSL 1.1.1g FIPS  21 Apr 2020)
TLS SNI support enabled
configure arguments: --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-stream_ssl_preread_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-http_auth_request_module --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-google_perftools_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E'


下载地址:https://github.com/happyfish100
fastdfs-6.07.tar.gz
fastdfs-nginx-module-1.22.tar.gz
libfastcommon-1.0.48.tar.gz

安装编译工具及库文件
yum -y install make zlib zlib-devel gcc-c++ libtool  openssl openssl-devel

mkdir -p /data/fastdfs && cd /data/fastdfs

解压下载好的包
tar -zxvf fastdfs-6.07.tar.gz 
tar -zxvf fastdfs-nginx-module-1.22.tar.gz 
tar -zxvf libfastcommon-1.0.48.tar.gz 

cd libfastcommon-1.0.48
编译安装 libfastcommon
./make.sh && ./make.sh install

检查
[root@yfm03 libfastcommon-1.0.48]# ls /usr/lib64|grep libfastcommon
libfastcommon.so
[root@yfm03 libfastcommon-1.0.48]# ls /usr/lib|grep libfastcommon
libfastcommon.so

编译安装 fastdfs
cd fastdfs-6.07
编译安装
./make.sh && ./make.sh install
检查
[root@yfm03 fastdfs-6.07]# ls /usr/bin|grep fdfs
fdfs_appender_test
fdfs_appender_test1
fdfs_append_file
fdfs_crc32
fdfs_delete_file
fdfs_download_file
fdfs_file_info
fdfs_monitor
fdfs_regenerate_filename
fdfs_storaged
fdfs_test
fdfs_test1
fdfs_trackerd
fdfs_upload_appender
fdfs_upload_file

启用配置文件
cd /etc/fdfs/
cp storage.conf.sample storage.conf
cp client.conf.sample client.conf
cp tracker.conf.sample tracker.conf
mkdir -p /data/fastdfs/tracker

vim /etc/fdfs/tracker.conf
base_path = /data/fastdfs/tracker

启动 tracker 服务
[root@yfm03 fdfs]# /etc/init.d/fdfs_trackerd start
Reloading systemd:                                         [  OK  ]
Starting fdfs_trackerd (via systemctl):                    [  OK  ]
[root@yfm03 fdfs]# ps -ef|grep fdfs
root       2116      1  0 19:40 ?        00:00:00 /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf
root       2124   1268  0 19:41 pts/0    00:00:00 grep --color=auto fdfs

mkdir -p /data/fastdfs/storage
修改 storage.conf 文件
vim /etc/fdfs/storage.conf
base_path = /data/fastdfs/storage
store_path0 = /data/fastdfs/storage
tracker_server = 192.168.199.103:22122
http.server_port = 80

启动 storage 服务
/etc/init.d/fdfs_storaged start

编辑 client.conf 文件
vim /etc/fdfs/client.conf
base_path = /data/fastdfs/tracker
tracker_server=192.168.199.103:22122

安装 nginx 和 fastdfs-nginx-module
因为我之前是用yum安装的nginx,这里演示下添加模块

mkdir -p /data/nginx && cd /data/nginx
wget http://nginx.org/download/nginx-1.16.1.tar.gz 
tar -zxvf nginx-1.16.1.tar.gz
cd nginx-1.16.1

yum install -y perl-ExtUtils-Embed readline-devel zlib-devel pam-devel libxml2-devel libxslt-devel openldap-devel python-devel gcc-c++   openssl-devel cmakepcre-develnanowget  gcc gcc-c++ ncurses-devel perl
yum install -y gcc gcc-c++ make cmake bison autoconf wget lrzsz  libtool libtool-ltdl-devel freetype-devel libjpeg.x86_64 libjpeg-devel libpng-devel gd-devel  python-develpatchsudo openssl* openssl openssl-devel ncurses-devel  bzip* bzip2 unzip zlib-devel libevent* libxml* libxml2-devel libcurl* curl-devel  readline-devel

mv /usr/sbin/nginx /usr/sbin/nginx.back 
cp -rf /etc/nginx /etc/nginx.back


./configure --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-stream_ssl_preread_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-http_auth_request_module --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-google_perftools_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E' --add-module=/data/fastdfs/fastdfs-nginx-module-1.22/src

报错
checking for --with-ld-opt="-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E" ... not found
yum -y install redhat-rpm-config.noarch

./configure: error: the Google perftools module requires the Google perftools
yum install gperftools -y

由于原先已有nginx,所以不能执行make install,否则会覆盖掉以前的配置文件及内容
make
cp objs/nginx /usr/sbin/nginx
systemctl restart nginx  

启动失败
journalctl -xe
nginx: [emerg] dlopen() "/usr/lib64/nginx/modules/ngx_mail_module.so" failed (/usr/lib64/nginx/modules/ngx_mail_module.so: undefined symbol: SSL_CT

在 objs目录下,还有许多插件配置文件,直接复制/usr/lib64/nginx/modules/下覆盖
cp -rf /usr/lib64/nginx/modules /usr/lib64/nginx/modules-bak
[root@yfm03 nginx-1.16.1]# mv objs/*.so /usr/lib64/nginx/modules/
mv: overwrite ‘/usr/lib64/nginx/modules/ngx_http_image_filter_module.so’? y
mv: overwrite ‘/usr/lib64/nginx/modules/ngx_http_perl_module.so’? y
mv: overwrite ‘/usr/lib64/nginx/modules/ngx_http_xslt_filter_module.so’? y
mv: overwrite ‘/usr/lib64/nginx/modules/ngx_mail_module.so’? y
mv: overwrite ‘/usr/lib64/nginx/modules/ngx_stream_module.so’? y

复制并修改fastdfs-ngin-module中的配置文件
cp /data/fastdfs/fastdfs-nginx-module-1.22/src/mod_fastdfs.conf /etc/fdfs/
vim /etc/fdfs/mod_fastdfs.conf
connect_timeout=10
tracker_server=192.168.199.103:22122
url_have_group_name = true
store_path0=/data/fastdfs/storage

将fastdfd源码conf目录http.conf,mime.types两个文件拷贝到/etc/fdfs/目录下
cp /data/fastdfs/fastdfs-6.07/conf/http.conf /etc/fdfs/
cp /data/fastdfs/fastdfs-6.07/conf/mime.types /etc/fdfs/

创建一个软连接,在/data/fastdfs/storage文件存储目录下创建软连接,将其链接到实际存放数据 的目录
mkdir -p /data/fastdfs/storage/data
mkdir -p /data/fastdfs/storage/data/M00
ln -s /data/fastdfs/storage/data /data/fastdfs/storage/data/M00

编辑 nginx 配置
vi /etc/nginx/nginx.conf
server {
    listen       80 default_server;
    listen       [::]:80 default_server;
    server_name  192.168.199.103;
    root         /usr/share/nginx/html;

    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

    location ~/group([0-9])/M00 {
        root  /data/fastdfs/storage/data;
        ngx_fastdfs_module;
	}
}


测试
下载测试图片到本地
wget -c "https://t.ki4.cn/2019/10/zau26v.jpg" -O springboot.jpg
上传测试图片
[root@yfm03 data]# /usr/bin/fdfs_upload_file /etc/fdfs/client.conf /data/springboot.jpg
group1/M00/00/00/wKjHZ2BjIyCAdohlAACumtGPxf4547.jpg

访问http://192.168.199.103/group1/M00/00/00/wKjHZ2BjIyCAdohlAACumtGPxf4547.jpg

在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

四美

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值