1. 程式人生 > >一、CentOS7下搭建FastDFS+Nginx實現靜態圖片服務器

一、CentOS7下搭建FastDFS+Nginx實現靜態圖片服務器

文件 源碼 wsgi ide 管理 配置 ror centos7 tor

在集群環境下,圖片存放在本地存在諸多限制,一般采用單獨的圖片服務器進行管理。FastDFS就是這樣一個圖片管理服務器。

環境需求,CentOS7下

一.先下載三件套,並上傳到服務器中(Nginx自行下載),地址如下

  1:libfastcommon    https://github.com/happyfish100/libfastcommon/archive/V1.0.7.tar.gz

  2:fastdfs    https://github.com/happyfish100/fastdfs/archive/V5.05.tar.gz

  3:fastdfs-nginx-module    http://jaist.dl.sourceforge.NET/project/fastdfs/FastDFS%20Nginx%20Module%20Source%20Code/fastdfs-nginx-module_v1.16.tar.gz

二.安裝FastDFS需要先將官網下載的源碼進行編譯,編譯依賴gcc環境,如果沒有gcc環境,需要安裝gcc:yum install gcc-c++

三.安裝FastDFS之前,先安裝libevent工具包。yum -y install libevent

四.安裝libfastcommonV1.0.7工具包。

  1、解壓縮

  2、./make.sh  //先編譯

  3、./make.sh install

五.安裝tracker和storage(如果正式開發環境一般是安裝在多臺服務器上,需要多次重新安裝)

  1、解壓縮

  2、./make.sh

  3、./make.sh install。安裝後在/usr/bin/目錄下有以fdfs開頭的文件都是編譯出來的。配置文件都放到/etc/fdfs文件夾

  4、把/root/FastDFS/conf目錄下的所有的配置文件都復制到/etc/fdfs下。

  5、配置tracker服務。修改/root/FastDFS/conf/tracker.conf文件。

    base_path=/home/fastdfs/tracker

  6、配置storage服務。修改/root/FastDFS/conf/storage.conf文件。

    base_path=/home/fastdfs/storage

    store_path0=/home/fastdfs/storage

    tracker_server=192.168.10.134:22122

  7、配置client服務。修改/root/FastDFS/conf/client

.conf文件。

    base_path=/home/fastdfs/client

  8、測試是否成功

    /usr/bin/fdfs_test /etc/fdfs/client.conf upload /etc/fdfs/anti-steal.jpg

    如果正常輸出路徑如:example file url: http://192.168.10.134/group1/M00/00/00/wKgKhlmVwZSAZYk5AABdrZgsqUU888_big.jpg

    則表示配置成功!

六.安裝nginx並添加fastdfs模塊插件

  1.先在centOS上配置好對應的依賴關系,免得麻煩

    yum install gcc-c++(之前裝過的可以省略)

    yum install -y pcre pcre-devel

    yum install -y zlib zlib-devel、

  2.對nginx重新config 

    技術分享
./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=/root/fastdfs-nginx-module/src
View Code

一、CentOS7下搭建FastDFS+Nginx實現靜態圖片服務器