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

相关内容

热门资讯

重达11000克拉!缅甸发现“... 【环球网报道】美国哥伦比亚广播公司、英国天空新闻网等媒体援引缅甸官方媒体8日消息报道称,缅甸发现一块...
玻璃缝隙漏水怎么处理 1、检查窗户玻璃附近墙体的防水层,重新做防水层。2、查找原先的密封物,检查门窗与墙体的密封度,如果密...
热水器侧面的缝隙漏水可以修好吗 问题:热水器侧面的缝隙漏水可以修好吗回答:如果热水器侧面出现缝隙漏水的情况基本上都是可以修好的。首先...
洗面盆和台面缝隙漏水怎么办 洗菜盆漏水的修补方法1、如果是洗菜盆和台面衔接松动:如果是因为洗菜盆安装时没安装好,与台面缝隙过大,...
空调缝隙漏水怎么办 空调在一定的年限服务后,会出现一些问题,例如漏水。空调漏水是比较常见的问题,但有许多原因可能导致空调...
不用电的情况下空气开关跳闸是怎... 家用空气断路器跳闸的原因很好判断,如果漏电断路器脱扣后复位按钮突出,则可以断定电路有漏电,需要注意的...
宏福苑母亲节晚宴,女儿希望火中... 凤凰卫视记者在香港报道:有慈善机构为大埔宏福苑居民举办母亲节晚宴,参加的居民表示,经历大火后更深刻体...
顺风车乘客拒付高速费,00后车... 近日,江苏苏州一00后车主接了一单顺风车,车主称下单时乘客已经点击确定承担全部高速费,可下高速时乘客...
圣罗兰“拉黑”杭州一条街道?记... 澎湃新闻记者 王选辉 实习生 俞涵因“恶意退货太多整条街道被商家拉黑”一事持续发酵,近日有网友反映,...
局地可达35℃以上!今年首轮高... 热起来了!今天(10日)起至13日,北方迎来今年首场大范围高温天气,大部地区气温将超30℃,刷新今年...