zoukankan      html  css  js  c++  java
  • Linux 安装FastDFS<单机版>(使用Mac远程访问)

    阅读本文需要先阅读安装FastDFS<准备>

    一 编译环境

    yum install gcc-c++

    yum -y install libevent

    yum install -y pcre pcre-devel

    yum install -y zlib zlib-devel

    yum install -y openssl openssl-devel

    二 安装libfastcommon

    新建目录

      mkdir /usr/local/libfastcommon

    解压

      cd libfastcommon压缩包所在目录

      tar -xvf libfastcommon-1.0.36.tar.gz -C /usr/local/libfastcommon

    编译

      cd /usr/local/libfastcommon/libfastcommon-1.0.36

      ./make.sh

      ./make.sh install

    三 安装FastDFS

    新建目录

      mkdir /usr/local/fastdfs

    解压

      cd fastdfs压缩包所在目录

      tar -xvf fastdfs-5.11.tar.gz -C /usr/local/fastdfs

    编译

      cd /usr/local/fastdfs/fastdfs-5.11

      ./make.sh

      ./make.sh install

    四 安装fastdfs-nginx-module

    解压

      cd fastdfs-nginx-module压缩包所在目录

      tar -xvf fastdfs-nginx-module.tar.gz -C /usr/local

    五 安装Nginx

    新建目录

      mkdir /usr/local/nginx

      mkdir -p /var/temp/nginx

    解压

      cd nginx压缩包所在目录

      tar -xvf nginx-1.14.0.tar.gz

    使用configure命令创建Makefile文件 将下面命令拷贝进去

      cd nginx解压包内部 -> cd /hy/nginx-1.14.0

    ./configure 
    --prefix=/usr/local/nginx 
    --pid-path=/var/run/nginx/nginx.pid 
    --lock-path=/var/lock/nginx.lock 
    --error-log-path=/var/log/nginx/error.log 
    --http-log-path=/var/log/nginx/access.log 
    --with-http_gzip_static_module 
    --http-client-body-temp-path=/var/temp/nginx/client 
    --http-proxy-temp-path=/var/temp/nginx/proxy 
    --http-fastcgi-temp-path=/var/temp/nginx/fastcgi 
    --http-uwsgi-temp-path=/var/temp/nginx/uwsgi 
    --http-scgi-temp-path=/var/temp/nginx/scgi 
    --add-module=/usr/local/fastdfs-nginx-module/src

    编译

      make

      make install

    六 配置文件准备

    cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf

    cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf

    cp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf

    cp /usr/local/fastdfs/fastdfs-5.11/conf/http.conf /etc/fdfs/

    cp /usr/local/fastdfs/fastdfs-5.11/conf/mime.types /etc/fdfs/

    cp /usr/local/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs

    七 配置Tracker

    新建目录

      mkdir -p /home/fastdfs/tracker

    编辑(根据key修改value)

      vim /etc/fdfs/tracker.conf

    # tracker服务器端口(默认22122 一般不修改)
    port=22122  
    # 存储tracker跟踪服务器日志和数据的根目录
    base_path=/home/fastdfs/tracker

    启动

      /etc/init.d/fdfs_trackerd start

    设置开机自动启动

      chkconfig fdfs_trackerd on

    八 配置Storage

    新建目录

      mkdir -p /home/fastdfs/storage

    编辑(根据key修改value)

      vim /etc/fdfs/storage.conf

    # storage服务器端口(默认23000 一般不修改)
    port=23000
    # 存储storage存储服务器日志和数据的根目录
    base_path=/home/fastdfs/storage
    # 第一个存储目录
    store_path0=/home/fastdfs/storage
    # tracker服务器IP和端口
    tracker_server=192.168.0.xxx:22122
    # http访问文件的端口(默认8888 看情况修改 和nginx中保持一致)
    http.server_port=8888

    启动

      /etc/init.d/fdfs_storaged start

    设置开机自动启动

      chkconfig fdfs_storaged on

    九 配置Nginx

    编辑(根据key修改value)

      vim /etc/fdfs/mod_fastdfs.conf

    # tracker服务器IP和端口
    tracker_server=192.168.0.xxx:22122
    # url中包含group名称
    url_have_group_name=true
    # storage.conf -> store_path0
    store_path0=/home/fastdfs/storage

    配置nginx服务器 将下面配置拷贝进去(与原有的server节点同级)

      vim /usr/local/nginx/conf/nginx.conf

        server {
            listen       8888;    #storage.conf -> http.server_port
            server_name  localhost;
    
            location ~/group[0-9]/ {
                ngx_fastdfs_module;
            }
    
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
        }

    进入sbin目录

      cd /usr/local/nginx/sbin

    启动

      ./nginx

    十 测试

    编辑(根据key修改value)

      vim /etc/fdfs/client.conf

    # tracker.conf -> store_path
    base_path=/home/fastdfs/tracker
    # tracker服务器IP和端口
    tracker_server=192.168.0.xxx:22122

    使用格式

      fdfs_upload_file 客户端配置文件地址 上传文件

      fdfs_upload_file /etc/fdfs/client.conf /usr/local/fastdfs/fastdfs-5.11/conf/anti-steal.jpg

    返回ID表示成功

      group1/M00/00/00/rBJeP1s4PoCAGfkiAABdrZgsqUU790.jpg

    用外部浏览器访问

      http://192.168.0.xxx:8888/group1/M00/00/00/rBJeP1s4PoCAGfkiAABdrZgsqUU790.jpg

  • 相关阅读:
    会议记录-5月20日
    会议记录-5月19日
    会议记录—5月18日
    会议记录-5月17日
    会议记录-5月16日
    会议记录-5月13日
    团队博客
    学习进度总结
    校外实习总结
    校外实习报告(二十)
  • 原文地址:https://www.cnblogs.com/huangyi-427/p/9249750.html
Copyright © 2011-2022 走看看