Nginx 配置 fastdfs-nginx-module 模块
admin
2023-03-19 06:41:32
0次

上篇介绍了FastDFS的安装,这里主要是给NG安装fastdfs-nginx-module 模块,来完成FastDFS的上传与下载


安装 Nginx 和 fastdfs-nginx-module

[root@EST-01 softwares]#wget -c https://nginx.org/download/nginx-1.10.1.tar.gz
fastdfs-nginx-module 直接用附件中的,网上下载的貌似有很多很问题
 
[root@EST-01 softwares]#tar -zxvf nginx-1.10.1.tar.gz 
[root@TEST-01 softwares]#unzip fastdfs-nginx-module-master.zip
[root@TEST-01 softwares]#cd nginx-1.10.1
[root@TEST-01 nginx-1.10.1]# ./configure --add-module=../fastdfs-nginx-module-master/src/  
[root@TEST-01 nginx-1.10.1]#make
[root@TEST-01 nginx-1.10.1]#make install
[root@TEST-01 nginx-1.10.1]#cd /usr/local/nginx/

我们可以看一下 Nginx 下安装成功的版本及模块
[root@TEST-01 nginx]# sbin/nginx -V
nginx version: nginx/1.10.1
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC) 
configure arguments: --add-module=../fastdfs-nginx-module-master/src/


配置 fastdfs-nginx-module 和 Nginx

[root@TEST-01 nginx]#cp /data/softwares/fastdfs-nginx-module-master/src/mod_fastdfs.conf /etc/fdfs/
[root@TEST-01 nginx]#vi /etc/fdfs/mod_fastdfs.conf (修改以下三处)
......
tracker_server=192.168.12.102:22122
.......
url_have_group_name = true
.......
store_path0=/data/fastdfs/storage
....

拷贝相关文件到/etc/fdfs
[root@TEST-01 nginx]#cp /data/softwares/fastdfs-5.05/conf/anti-steal.jpg /etc/fdfs/
[root@TEST-01 nginx]#cp /data/softwares/fastdfs-5.05/conf/http.conf /etc/fdfs/
[root@TEST-01 nginx]#cp /data/softwares/fastdfs-5.05/conf/mime.types /etc/fdfs/


 编辑nginx.conf
 [root@TEST-01 nginx]#vi conf/nginx.conf
 .....
          location /group1/M00 {
             root /data/fastdfs/storage/;
             ngx_fastdfs_module;
         }
 .....
 
[root@TEST-01 nginx]#mkdir /data/fastdfs/storage/data/group1
[root@TEST-01 nginx]#ln -s /data/fastdfs/storage/data /data/fastdfs/storage/data/group1/M00 
启动nginx
[root@TEST-01 nginx]#sbin/nginx 
ngx_http_fastdfs_set pid=17697

这样就完成了Nginx  配置 fastdfs-nginx-module 模块

测试下:

开启上传

[root@TEST-01 nginx]#cd /etc/fdfs/
[root@TEST-01 fdfs]#cp client.conf.sample client.conf
......
# the base path to store log files
base_path=/data/fastdfs

# tracker_server can ocur more than once, and tracker_server format is
#  "host:port", host can be hostname or ip address
tracker_server=192.168.12.102:22122
.......

好了,上传一张图片试试

[root@TEST-01 fdfs]#fdfs_test /etc/fdfs/client.conf upload /tmp/Tulips.jpg
This is FastDFS client test program v5.05

Copyright (C) 2008, Happy Fish / YuQing

FastDFS may be copied only under the terms of the GNU General
Public License V3, which may be found in the FastDFS source kit.
Please visit the FastDFS Home Page http://www.csource.org/ 
for more detail.

[2017-06-23 09:38:47] DEBUG - base_path=/data/fastdfs, connect_timeout=30, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s, use_storage_id=0, storage server id count: 0

tracker_query_storage_store_list_without_group: 
        server 1. group_name=, ip_addr=192.168.12.102, port=23000

group_name=group1, ip_addr=192.168.12.102, port=23000
storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/wKgMZllMcSeAb4ChAAl5WLU-YRY168.jpg
source ip address: 192.168.12.102
file timestamp=2017-06-23 09:38:47
file size=620888
file crc32=3040764182
example file url: http://192.168.12.102/group1/M00/00/00/wKgMZllMcSeAb4ChAAl5WLU-YRY168.jpg
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/wKgMZllMcSeAb4ChAAl5WLU-YRY168_big.jpg
source ip address: 192.168.12.102
file timestamp=2017-06-23 09:38:47
file size=620888
file crc32=3040764182
example file url: http://192.168.12.102/group1/M00/00/00/wKgMZllMcSeAb4ChAAl5WLU-YRY168_big.jpg

上传后,图片的URL也会出现,我们访问试试


Nginx  配置 fastdfs-nginx-module 模块







附件:http://down.51cto.com/data/2366780

相关内容

热门资讯

空调连续工作多久需要停机休息 空调连续工作的时间取决于多个因素,包括空调的型号、功率、使用环境和维护情况等。一般来说,空调可以连续...
空调哪个符号是除湿的 空调除湿功能通常用一个水滴形状的符号表示。不同品牌和型号的空调遥控器可能会有所差异,但一般来说,除湿...
格力空调多长时间加一次氟利昂 1、一般情况下,空调对氟利昂的使用量是非常小的,所以在空调使用了四年左右的时候再考虑加也没问题。2、...
空调用多长时间需要加氟一次 一般情况下是五年。当出现以下这几种情况时,空调才需要加氟。1、空调的室内机和室外机各有两个接口,当接...
格调生活·C标思享荟:卡萨帝在... 9月12日的郑州龙湖金融岛,夜风轻拂,灯光璀璨。“C标时刻共传奇——卡萨帝思享荟暨20周年品牌盛典郑...
品牌价值破千亿、高端份额持续领... 9月12日,“C标时刻共传奇——卡萨帝思享荟暨20周年品牌盛典郑州站”在郑州龙湖金融岛举办。2026...
空调主板坏了修800还是换新的 空调主板坏了是修还是换新,需要考虑多个因素,以下是一些建议:1. 维修成本:如果维修费用较低,比如 ...
空调开多久需要休息多长时间 问题:空调开多久需要休息多长时间回答:1、在使用空调的过程中,一般空调开7~8个小时左右需要休息2~...
中央空调多长时间清洗一次 1、一般空调开机前清洗一次即可,空调开机中间时段再清洗一次,空调关机时清洗一次,这样比较合理。2、空...
中央空调氟利昂多久加一次 看空调制热和制冷程度,很多人的观点认为氟利昂必须一年放一次,其实这个观点是错误的,理解上面有点偏差,...