博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
linux下搭建 FastDFS + Nginx
阅读量:6896 次
发布时间:2019-06-27

本文共 3558 字,大约阅读时间需要 11 分钟。

hot3.png

FastDfs 依赖 libevent。

 

先决条件:

  1. 测试环境目录为: /home/users/wangyanpei/

  2. libevent 版本: 2.0.21-stable

  3. Fastdfs 版本: FastDFS_v4.06.tar.gz

  4. Nginx 版本: 1.6.0

  5. fastdfs-nginx-module版本: fastdfs-nginx-module_v1.15.tar.gz

安装路径:

     nginx: /home/users/wangyanpei/nginx

     fastdfs : /home/users/wangyanpei/FastDFS

     tracker路径: /home/users/wangyanpei/tracker/

     storage路径: /home/users/wangyanpei/storage/

     libevent 路径:/home/users/wangyanpei/libevent-2.0.21

 

 

 

   第一步:安装libevent:

       wget  放到 /home/users/wangyanpei/setup/

       tar zxvf libevent-2.0.21-stable.tar.gz

       cd libevent-2.0.21-stable

       ./configure --prefix=/home/users/wangyanpei/libevent-2.0.21

       make & make install

     

  第二部:安装FastDFS

     wget  到 /home/users/wangyanpei/setup/

     tar zxvf FastDFS_v4.06.tar.gz

     cd FastDFS

     vim make.sh【配置安装路径】

        TARGET_PREFIX=/home/users/miaolinjie/FastDFS   ---安装路径

        TARGET_CONF_PATH=/home/users/miaolinjie/FastDFS/conf  ---配置文件路径

        WITH_LINUX_SERVICE=1  ---是否为linux服务

     ./make.sh C_INCLUDE_PATH=/home/users/wangyanpei/libevent-2.0.21/include LIBRARY_PATH=/home/users/miaolinjie/libevent-2.0.21/lib/

     ./make install

 

  第三步:安装Nginx 和 fastdfs-nginx-module

       wget 

       到 /home/users/wangyanpei/setup下

       解压

       cd fastdfs-nginx-module/src/

       vim config[修改依赖lib和include文件路径]

            CORE_INCS="$CORE_INCS /home/users/wangyanpei/FastDFS/include/fastdfs /home/users/wangyanpei/FastDFS/include/fastcommon/"

            CORE_LIBS="$CORE_LIBS -L/home/users/wangyanpei/FastDFS/include/lib -lfastcommon -lfdfsclient"

            CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -                DFDFS_MOD_CONF_FILENAME='\"/home/users/wangyanpei/FastDFS/conf/mod_fastdfs.conf\"'"

      将fastdfs-nginx-module的mod_fastdfs.conf 拷贝到config中指定的路径下:        

      cp /home/users/wangyanpei/setup/fastdfs-nginx-module/src/mod_fastdfs.conf /home/users/miaolinjie/FastDFS/conf

        安装Nginx:

         cd Nginx_1.6.0

         ./configure --prefix=/home/users/wangyanpei/nginx --conf-path=/home/users/wangyanpei/nginx/conf/nginx.conf --add-module=/home/users/wangyanpei/setup/fastdfs-nginx-module/src/

         make && make install

      启动nginx, 如果启动不了 将fastdfs的目录拷贝到对应目录下就可以。

        ./sbin/nginx -c conf/nginx.conf

        

第四步: 配置tracker server

         vim conf/tracker.conf

         bind_addr=本机ip 

         base_path=/home/users/wangyanpei/tracker/【该目录保存tracker知道的信息和log】

         启动:

         ./bin/fdfs_trackerd ./conf/tracker.conf

   

第五步: 配置storage server

        vim conf/storage.conf

        group_name=group1  隶属于哪个group

        bind_addr

        base_path=/home/users/wangyanpei/storage

        store_path0=/home/users/wangyanpei/storage

         tracker_server=ip:port

         http.server_port=8090

        启动

        ./bin/fdfs_storaged ./conf/storage.conf

第六步: 修改 mod_fastdfs.conf   

        base_path=/home/users/wangyanpei/storage

        group_name=group1

        store_path0=/home/users/wangyanpei/storage

        tracker_server=ip:port

        url_have_group_name=true

 第七步: 修改client.conf 

       base_path=/home/users/wangyanpei/storage

       tracker_server=ip:port

       http.tracker_server_port=8090

第八步: 修改nginx.conf

      location /group1/M00 {

           root /home/users/wangyanpei/storage/data;

            ngx_fastdfs_module;   

     }

重启nginx

第九步:测试

     ./bin/fdfs_test ./conf/client.conf upload /etc/passwd

结果:

    

tracker_query_storage_store_list_without_group:

server 1. group_name=, ip_addr=182.92.128.99, port=23001

group_name=group1, ip_addr=182.92.128.99, port=23001

storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/tlyAY1WJEWqAKulyAAAGPHfAkyI2479341
source ip address: 182.92.128.99
file timestamp=2015-06-23 15:57:30
file size=1596
file crc32=2009109282
file url: 
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/tlyAY1WJEWqAKulyAAAGPHfAkyI2479341_big
source ip address: 182.92.128.99
file timestamp=2015-06-23 15:57:30
file size=1596
file crc32=2009109282
file url: 

       

浏览器中打开可以访问到上传文件。

转载于:https://my.oschina.net/wangyanpei/blog/485135

你可能感兴趣的文章
p2p
查看>>
Vue生命周期钩子函数
查看>>
通过MAVEN将JAVA工程中引用的外部JAR包一起打war包
查看>>
Tomcat源码学习探索笔记
查看>>
微信小程序image图片实现高度自适应
查看>>
基于jax-ws的webservice 简单实例
查看>>
33、C#里面的进度条和时钟组件的使用
查看>>
041、Linux服务器监控CPU温度
查看>>
进程管理工具htop/glances/dstat的使用
查看>>
支付宝H5和微信公众号H5支付
查看>>
配置Apache日志----防盗链
查看>>
我的友情链接
查看>>
JPA的实体
查看>>
我的友情链接
查看>>
MDT 2012 批量部署(六)——MDT捕获镜像
查看>>
RMAN--obsolete 和 expired的区别
查看>>
windows 2003集群中安装sharepoint 2007配置时用户名无效
查看>>
Initialization failed for block pool Block pool(转载)
查看>>
Oracle 备份与恢复学习笔记(4)
查看>>
jxl导出excel格式设定
查看>>