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已经在/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结合起来

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
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容