Linux 環境安裝文件服務器 FastDFS + Nginx(本人阿里雲安裝全過程)

一:資源準備

https://download.csdn.net/download/tianya900519/12272676

二:各種安裝

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-1.20.tar.gz
  fastdfs-5.12.tar.gz
  libfastcommon-1.0.40.tar.gz
  nginx-1.17.5.tar.gz

3.安裝libfastcommon
  進入libfastcommon 所在的目錄
  tar -zxvf libfastcommon-1.0.40.tar.gz -C  /usr/local/
  cd /usr/local/libfastcommon-1.0.40/
  ./make.sh
  ./make.sh install
  cd /usr
  cp lib64/libfastcommon.so lib/

4.安裝fastdfs主體程序
  tar -zxvf  fastdfs-5.12.tar.gz
  cd fastdfs-5.12/
  ./make.sh
  ./make.sh install

5.配置fastdfs之tracker
  cd /opt/fastdfs/fastdfs-5.12/conf/
  cp ./* /etc/fdfs/
    cd /etc/fdfs/
    mkdir -p /opt/fastdfs/tracker
  vim tracker.conf
  22 #base_path=/home/yuqing/fastdfs
  23 base_path=/opt/fastdfs/tracker
    退出vim
  /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
    ---------------驗證tracker是否正常啓動----------------------
    [root@iZwz9f6fcu6q1uwaahfebyZ fdfs]# ps -ef|grep trackerd|grep -v grep
    root     23864     1  0 10:13 ?        00:00:00 /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
    [root@iZwz9f6fcu6q1uwaahfebyZ fdfs]# netstat -anp|grep 23864
    tcp        0      0 0.0.0.0:22122           0.0.0.0:*               LISTEN      23864/fdfs_trackerd 

6.配置fastdfs之storage
  mkdir -p /opt/fastdfs/storage
  vim /etc/fdfs/storage.conf
  41 #base_path=/home/yuqing/fastdfs
  42 base_path=/opt/fastdfs/tracker
  110 # store_path0=/home/yuqing/fastdfs
  111 store_path0=/opt/fastdfs/storage
  120 tracker_server=172.18.58.251:22122
    退出vim
  /usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
    ---------------驗證storage是否正常啓動----------------------
  [root@iZwz9f6fcu6q1uwaahfebyZ fdfs]# ps -ef|grep storaged|grep -v grep
    root     23898     1  8 10:25 ?        00:00:00 /usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
    [root@iZwz9f6fcu6q1uwaahfebyZ fdfs]# netstat -anp|grep 23898
    tcp        0      0 0.0.0.0:23000           0.0.0.0:*               LISTEN      23898/fdfs_storaged 
    tcp        0      0 172.18.58.251:49578     172.18.58.251:22122     ESTABLISHED 23898/fdfs_storaged 

7.配置fastdfs之client
  vim /etc/fdfs/client.conf
  base_path=/opt/fastdfs/tracker
  tracker_server=172.18.58.251:22122
    http.tracker_server_port=9080

8.安裝Nginx並和FastDFS整合
    進入fastdfs-nginx-module所在的目錄
    tar -zxvf fastdfs-nginx-module-1.20.tar.gz -C  /usr/local/
  cd /usr/local/fastdfs-nginx-module-1.20/src
  vim config
  CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"
    退出vim
  cp mod_fastdfs.conf /etc/fdfs/
  vim /etc/fdfs/mod_fastdfs.conf
    ---------------需要修改的內容------------------
    #base_path=/tmp
  base_path=/opt/fastdfs/tracker
  tracker_server=172.18.58.251:22122
  url_have_group_name=true #URL中包含group名稱
  store_path0=/opt/fastdfs/storage #指定文件存儲路徑
    -----------------------------------------------
    退出vim

    進入Nginx文件所在目錄
  tar -zxvf nginx-1.17.5.tar.gz
  cd nginx-1.17.5
    ./configure --prefix=/opt/fastdfs/nginx-1.17.5 --add-module=/usr/local/fastdfs-nginx-module-1.20/src --with-http_image_filter_module --without-http_gzip_module
    
    出現的錯誤
    ./configure: error: the HTTP image filter module requires the GD library.
    yum -y install gd-devel
    ./configure: error: the GeoIP module requires the GeoIP library.
    yum -y install GeoIP GeoIP-devel GeoIP-data

    Ubuntu 系統解決GD庫問題:sudo apt-get install libgd2-xpm-dev
    
  make
  make install
  vim conf/nginx.conf
    -------------加入如下內容-----------------
  server{
        listen 8088;
        server_name localhost;
        location ~/group([0-9])/M00 {
        root /opt/fastdfs/storage/data;
        ngx_fastdfs_module;
    }
    -------------------------------------------
    退出vim
    啓動
  /opt/fastdfs/nginx-1.17.5/sbin/nginx

    配置Nginx開機自動啓動
  vim /etc/rc.d/rc.local
  /opt/fastdfs/nginx-1.17.5/sbin/nginx

    -----------------
    service iptables stop
    設置防火牆開機不啓動
  chkconfig iptables off

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章