CentOS7安裝fastdfs

CentOS7安裝fastdfs

安裝CentOS基本依賴:

 yum -y install tcl lrzsz deltarpm zlib zlib-devel pcre pcre-devel gcc gcc-c++ openssl openssl-devel libevent libevent-devel perl unzip net-tools wget

所需安裝包:

fastdfs-5.11.tar.gz
fastdfs-nginx-module-1.20.tar.gz
libfastcommon-1.0.39.tar.gz
nginx-1.15.8.tar.gz

1.安裝common

1.解壓:tar -zxvf libfastcommon-1.0.39.tar.gz
2.編譯和安裝:cd libfastcommon-1.0.39 && ./make.sh && ./make.sh install
3.查看安裝好以后的common文件:cd /usr/lib && ll libfast*

2.安裝tracker服務

1.解壓:tar -zxvf fastdfs-5.11.tar.gz
  注:把一些會用到的庫先拷貝到/etc/fdfs下
  cp /development/fastdfs-5.11/conf/mime.types /etc/fdfs/
  cp /development/fastdfs-5.11/conf/http.conf /etc/fdfs/
2.編譯和安裝:cd fastdfs-5.11 && ./make.sh && ./make.sh install
3.查看安裝好以后的dfs文件:
  cd /usr/bin && ll fdfs*
  cd /etc/fdfs && ll fdfs*
4.把解壓出的fastdfs-5.11中的conf目錄
5.配置tracker.conf
  vim /development/fastdfs-5.11/conf/tracker.conf
  修改base_path
    base_path=/development/fastdfs/tracker
6.新建相關目錄
  mkdir /development/fastdfs/tracker -p
  mkdir /development/fastdfs/client -p
  mkdir /development/fastdfs/storage -p
  mkdir /development/fastdfs/tmp -p
  mkdir /var/temp/nginx/client -p
7.啟動服務
  (fdfs_trackerd已經(jīng)在/usr/bin目錄下)
  fdfs_trackerd /development/fastdfs-5.11/conf/tracker.conf
  fdfs_trackerd /development/fastdfs-5.11/conf/tracker.conf stop
  fdfs_trackerd /development/fastdfs-5.11/conf/tracker.conf restart

3.安裝storage服務

vim /development/fastdfs-5.11/conf/storage.conf
1.配置storage.conf
  修改base_path,group_name,store_path0,tracker_server,bind_addr
    group_name=source
    base_path=/development/fastdfs/storage
    store_path0=/development/fastdfs/storage
    tracker_server=當前ip
2.啟動服務
  fdfs_storaged /development/fastdfs-5.11/conf/storage.conf

4.配置client測試上傳

1.配置client.conf
  vim /development/fastdfs-5.11/conf/client.conf
  修改base_path,tracker_server
    tracker_server=當前ip
    base_path=/development/fastdfs/client
2.測試上傳(不支持直接上傳遠端圖片測試)
  fdfs_test /development/fastdfs-5.11/conf/client.conf upload /development/test.jpg
注:如果測試上傳不成功并且配置沒問題,可以試著重啟虛擬機再試  

5.將nginx和fastdfs結(jié)合起來

1.解壓:tar -xzvf fastdfs-nginx-module-1.20.tar.gz
2.修改配置文件:
  vim /development/fastdfs-nginx-module-1.20/src/config
  ngx_module_incs="/usr/include/fastdfs /usr/include/fastcommon"
  CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon"
3.安裝nginx
  解壓 tar -zxvf /development/nginx-1.15.8.tar.gz
  1.配置nginx
    cd /development/nginx-1.15.8
    ./configure \
      --prefix=/usr/local/nginx \
      --pid-path=/var/run/nginx/nginx.pid \
      --lock-path=/var/lock/nginx.lock \
      --error-log-path=/usr/local/nginx/errors/error.log \
      --http-log-path=/usr/local/nginx/logs/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=/development/fastdfs-nginx-module-1.20/src
  2.編譯安裝
    make && make install
    nginx目錄:/usr/local/nginx
  3.配置fastdfs-nginx-module
    vim /development/fastdfs-nginx-module-1.20/src/mod_fastdfs.conf
    mv /development/mod_fastdfs.conf/fastdfs-nginx-module-1.20/src/ /etc/fdfs
    修改base_path,tracker_server,group_name,url_have_group_name,store_path0
      base_path=/development/fastdfs
      store_path0=/development/fastdfs/storage
      tracker_server=當前ip:22122
      group_name=source
      url_have_group_name=true
  4.修改nginx主配置文件
    mkdir /usr/local/nginx/conf/conf.d
    vim /usr/local/nginx/conf/nginx.conf
#user  nobody;
        worker_processes  1;

        #error_log  logs/error.log;
        #error_log  logs/error.log  notice;
        #error_log  logs/error.log  info;

        #pid        logs/nginx.pid;


        events {
            worker_connections  1024;
        }


        http {
            include       mime.types;
            default_type  application/octet-stream;

            #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
            #                  '$status $body_bytes_sent "$http_referer" '
            #                  '"$http_user_agent" "$http_x_forwarded_for"';

            #access_log  logs/access.log  main;

            sendfile        on;
            #tcp_nopush     on;

            #keepalive_timeout  0;
            keepalive_timeout  65;

            #gzip  on;

            server {
                listen       80;
                server_name  localhost;

                #charset koi8-r;

                #access_log  logs/host.access.log  main;

                location / {
                    root   /home/www;
                    index  index.html index.htm;
                }

                #error_page  404              /404.html;

                # redirect server error pages to the static page /50x.html
                #
                error_page   500 502 503 504  /50x.html;
                location = /50x.html {
                    root   /home/www;
                }

                # proxy the PHP scripts to Apache listening on 127.0.0.1:80
                #
                #location ~ \.php$ {
                #    proxy_pass   http://127.0.0.1;
                #}

                # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
                #
                #location ~ \.php$ {
                #    root           html;
                #    fastcgi_pass   127.0.0.1:9000;
                #    fastcgi_index  index.php;
                #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
                #    include        fastcgi_params;
                #}

                # deny access to .htaccess files, if Apache's document root
                # concurs with nginx's one
                #
                #location ~ /\.ht {
                #    deny  all;
               #}
            }

            include conf.d/*.conf;

            # another virtual host using mix of IP-, name-, and port-based configuration
            #
            #server {
            #    listen       8000;
            #    listen       somename:8080;
            #    server_name  somename  alias  another.alias;

            #    location / {
            #        root   html;
            #        index  index.html index.htm;
            #    }
            #}
            
            # HTTPS server
            #
            #server {
            #    listen       443 ssl;
            #    server_name  localhost;

            #    ssl_certificate      cert.pem;
            #    ssl_certificate_key  cert.key;

            #    ssl_session_cache    shared:SSL:1m;
            #    ssl_session_timeout  5m;

            #    ssl_ciphers  HIGH:!aNULL:!MD5;
            #    ssl_prefer_server_ciphers  on;

            #    location / {
            #        root   html;
            #        index  index.html index.htm;
            #    }
            #}
        }
  5.增加fastdfs和nginx的配置文件
    vim /usr/local/nginx/conf/conf.d/fastdfs-server.conf
    server {
      listen 9870;
      server_name 192.168.160.182;
      location /source/M00 {
        ngx_fastdfs_module;
      }
    }
    注:不要忘記把此端口加入防火墻中

  6.啟動nginx
    檢測腳本是否配置正確 /usr/local/nginx/sbin/nginx -t
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容