FastDFS的安装步骤

1.安装相关环境
  yum install -y gcc-c++
  yum -y install libevent
  yum install -y pcre pcre-devel
  yum install -y zlib zlib-devel
  yum install -y openssl openssl-devel
2.上传文件
  fastdfs-nginx-module_v1.16.tar.gz
  FastDFS_v5.05.tar.gz
  libfastcommonV1.0.7.tar.gz
  nginx-1.8.0.tar.gz
3.安装libfastcommonV1.0.7.tar.gz
  进入libfastcommonV1.0.7.tar.gz所在的目录
  mv libfastcommonV1.0.7.tar.gz /usr/local/
  cd /usr/local/
  tar -zxvf libfastcommonV1.0.7.tar.gz
  cd libfastcommon-1.0.7/
  ./make.sh
  ./make.sh install
  cd /usr
  cp lib64/libfastcommon.so lib/
4.安装FastDFS主体程序
  tar -zxvf FastDFS_v5.05.tar.gz
  cd FastDFS
  ./make.sh
  ./make.sh install
5.配置FastDFS之tracker
  cd /root/FastDFS/conf/
  cp ./* /etc/fdfs/
  mkdir -p /home/FastDFS
  vim tracker.conf
  22 #base_path=/home/yuqing/fastdfs
  23 base_path=/home/FastDFS
退出vim
  /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
---------------验证tracker是否正常启动----------------------
  [root@right fdfs]# ps -ef|grep trackerd|grep -v grep
  root 34054 1 0 11:12 ? 00:00:00 /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
  [root@right fdfs]# netstat -anp|grep 34054
  tcp 0 0 0.0.0.0:22122 0.0.0.0:* LISTEN 34054/fdfs_trackerd
------------------------------------------------------------
6.配置FastDFS之storage
  mkdir -p /home/FastDFS/fdfs_storage
  vim /etc/fdfs/storage.conf
  41 #base_path=/home/yuqing/fastdfs
  42 base_path=/home/FastDFS
  110 # store_path0=/home/yuqing/fastdfs
  111 store_path0=/home/FastDFS/fdfs_storage
  120 tracker_server=192.168.159.249:22122
退出vim
  /usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
---------------验证storage是否正常启动----------------------
  [root@right fdfs]# ps -ef|grep storaged|grep -v grep
  root 34141 1 1 11:23 ? 00:00:00 /usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
  [root@right fdfs]# netstat -anp|grep 34141
  tcp 0 0 0.0.0.0:23000 0.0.0.0:* LISTEN 34141/fdfs_storaged
  tcp 0 0 192.168.159.249:56519 192.168.159.249:22122 ESTABLISHED 34141/fdfs_storaged
------------------------------------------------------------
7.配置FastDFS之client
  vim /etc/fdfs/client.conf
  base_path=/home/FastDFS
  tracker_server=192.168.159.134:22122
  /usr/bin/fdfs_test /etc/fdfs/client.conf upload /root/aaa.jpg
8.安装Nginx并和FastDFS整合
  mv fastdfs-nginx-module_v1.16.tar.gz /usr/local/
  cd /usr/local/
  tar -zxvf fastdfs-nginx-module_v1.16.tar.gz
  cd fastdfs-nginx-module/src
  vim config
-----------------修改后的内容---------------------
  1 ngx_addon_name=ngx_http_fastdfs_module
  2 HTTP_MODULES="$HTTP_MODULES ngx_http_fastdfs_module"
  3 NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_fastdfs_module.c"
  4 CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"
  5 CORE_LIBS="$CORE_LIBS -L/usr/lib -lfastcommon -lfdfsclient"
  6 CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -DFDFS_MOD_CONF_FILENAME='"/etc/fdfs/mod_fa stdfs.conf"'"
--------------------------------------------------
退出vim
  cp mod_fastdfs.conf /etc/fdfs/
  vim /etc/fdfs/mod_fastdfs.conf
---------------需要修改的内容------------------
  base_path=/home/FastDFS
  tracker_server=192.168.159.134:22122
  # tracker_server=192.168.159.132:22122(多个tracker配置多行)
  url_have_group_name=true #URL中包含group名称
  store_path0=/home/FastDFS/fdfs_storage #指定文件存储路径
-----------------------------------------------
退出vim
  mkdir -p /var/temp/nginx/client
进入Nginx文件所在目录
  tar -zxvf nginx-1.8.0.tar.gz
  cd nginx-1.8.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
  vim /usr/local/nginx/conf/nginx.conf
-------------加入如下内容-----------------
  server {
    listen 80;
    server_name 192.168.159.249;

    location /group1/M00/{
    ngx_fastdfs_module;
      }
    }
-------------------------------------------
退出vim
  /usr/local/nginx/sbin/nginx
  service iptables stop

配置Nginx开机自动启动
  vim /etc/rc.d/rc.local
  /usr/local/nginx/sbin/nginx

-----------------
设置防火墙开机不启动
  chkconfig iptables off

原文地址:https://www.cnblogs.com/androidsuperman/p/7639324.html