Installation and Configuration Nginx-fastdfs

FastDFS (Fast Distributed File System) is an open source lightweight distributed file system , I spent a day through the installation and configuration, the reference period: https: //www.cnblogs.com/handsomeye/p/9451568.html , sum up now, hoping that newcomers avoid detours.

环境:CentOS Linux release 7.3.1611 (Core)[cat /etc/redhat-release]

Install wget: yum install wget

安装lrzsz:yum install lrzsz

Install gcc: yum install gcc

Installation: yum install vim

Installation: yum groupinstall Development Tools

Installation libfastcommon

  1. Get libfastcommon installation package:wget https://github.com/happyfish100/libfastcommon/archive/V1.0.38.tar.gz

  2. Extracting installation package: tar -zxvf V1.0.38.tar.gz

  3. Enter the directory: cd libfastcommon-1.0.38

  4. Compile: ./ make.sh

  5. Installation: ./ make.sh install

Installation FastDFS

  1. Get fdfs installation package:wget https://github.com/happyfish100/fastdfs/archive/V5.11.tar.gz

  2. Extracting installation package: tar -zxvf V5.11.tar.gz

  3. Enter the directory: cd fastdfs-5.11

  4. Compile: ./ make.sh

  5. Installation: ./ make.sh install

Configuration Service Tracker

  1. Go to the / etc / fdfs directory, there are three .sample file suffix (automatically generated fdfs template configuration file), by cp command tracker.conf.sample copy, delete .sample suffix as an official document.

  2. Edit tracker.conf: vi tracker.conf, modify the relevant parameters

    base_path=/home/mm/fastdfs/tracker #tracker存储data和log的跟路径,必须提前创建好

    http.server_port=80 #http端口,需要和nginx相同

  3. Start tracker (support start | stop | restart):/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start

 

Configuring Storage Service

 

    1. Enter / etc / fdfs directory, there are cp command to copy storage.conf.sample, delete .sample suffix as an official document;
    2. Edit storage.conf: vi storage.conf, modify the relevant parameters:

      base_path=/home/fastdfs/storage   #storage存储data和log的跟路径,必须提前创建好 store_path0=/home/fastdfs/storage #如果为空,则使用base_path tracker_server=192.168.1.103:22122 #配置该storage监听的tracker的ip和port 
    3. Start storage (supports start | stop | restart):

      /usr/bin/fdfs_storaged /etc/fdfs/storage.conf start

 

Installation Nginx fastdfs-nginx-module and module

 

  1. Download Nginx installation package wget http://nginx.org/download/nginx-1.15.2.tar.gz

  2. Download fastdfs-nginx-module installation package wget https://github.com/happyfish100/fastdfs-nginx-module/archive/V1.20.tar.gz

  3. Decompression nginx: tar -zxvf nginx-1.15.2.tar.gz

  4. Decompression fastdfs-nginx-module: tar -xvf V1.20.tar.gz

  5. Installation depends libraries:yum install libpcre3 libpcre3-dev openssl libssl-dev libperl-dev

  6. Modify fastdfs-nginx-module-1.20 / src / config file: ngx_module_incs="/usr/include/fastdfs /usr/include/fastcommon/" CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/" 

  7. Into the directory nginx: nginx CD-1.15.2 , load the configuration module fastdfs-nginx-module:

  8. ./configure \
    --prefix=/usr/local/nginx \
    --pid-path=/var/run/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=/root/fastdfs-nginx-module-1.20/src

  9. Compile and install:make  -> make install 
  10. Check the installation path: whereis nginx
  11.  

    turn stop:
  12. cd /usr/local/nginx/sbin/ ./nginx ./nginx -s stop #此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程 ./nginx -s quit #此方式停止步骤是待nginx进程处理任务完毕进行停止 ./nginx -s reload 

 

Nginx configuration and fastdfs-nginx-module module

 

  1. Configuring mod-fastdfs.conf, and copied to the / etc / fdfs file directory

    cd fastdfs-nginx-module-1.20/src/ cp mod_fastdfs.conf /etc/fdfs 
  2. Enter / etc / fdfs modification mod-fastdfs.conf:

    base_path=/home/fastdfs/storage
    tracker_server=192.168.1.103:22122 #tracker的地址 url_have_group_name=true #url是否包含group名称 store_path0=/home/fastdfs/storage #文件存储的位置 
  3. Configuring nginx, new server:

    cd /usr/local/nginx/conf/ vim nginx.conf
  4. server {
            listen       80;
            server_name  192.168.1.103;
            location /group1/M00/ {
                ngx_fastdfs_module;
            }}
  5. A final copy of http.conf fastdfs unpacked directory and mime.types:cd /usr/local/src/fastdfs-5.11/conf
    cp mime.types http.conf /etc/fdfs/

测试服务:/usr/bin/fdfs_test /etc/fdfs/client.conf upload (指定配置文件)

example file url: http://192.168.1.107/group1/M00/00/00/wKgBa11_Lb2ADL_8AABdrSqbHGQ330_big.jpg

 

Guess you like

Origin www.cnblogs.com/gangzi4321/p/11537409.html