fastdfs 5.12 单机搭建

fastfds单机搭建

环境准备
  系统:Centos7
  fastdfs:到https://github.com/happyfish100下载,都下载最新的:fastdfs-master、libfastcommon-master、fastdfs-nginx-module-master,避免版本问题
fastdfs安装
上传相关包到/opt下
  安装zip、unzip
[root@fastdfs2 opt]# yum install -y unzip zip

   解压fastdfs-master.zip
          [root@fastdfs2 opt]# unzip -o fastdfs-master.zip -d /usr/local

   安装libfastcommon
          解压libfastcommon-master.zip

                 [root@fastdfs2 fastdfs-master]# cd /opt

                 [root@fastdfs2 opt]# unzip -o libfastcommon-master.zip -d /usr/local

          安装libfastcommon

                 [root@fastdfs2 opt]# cd /usr/local/libfastcommon-master/

                 [root@fastdfs2 libfastcommon-master]# ./make.sh

                 [root@fastdfs2 libfastcommon-master]# ./make.sh install

   再装fastdfs
          [root@fastdfs2 local]# cd /usr/local/fastdfs-master/

          [root@fastdfs2 fastdfs-master]# ./make.sh

          [root@fastdfs2 fastdfs-master]# ./make.sh install

   拷贝配置文件
          将fastdfs安装目录下的conf下的文件拷贝到/etc/fdfs/下

          [root@fastdfs2 fastdfs-master]# cp -r conf/* /etc/fdfs/

   自此fastdfs安装完成了,接下来配置trackerd和storaged,并启动它们。

配置并启动trackerd
修改trackerd.conf
不改也可以,但是要保证/home/yuqing/fastdfs路径存在

          [root@fastdfs2 fdfs]# cd /etc/fdfs/

          [root@fastdfs2 fdfs]# vi tracker.conf

          将base_path=/home/yuqing/fastdfs改成base_path=/data/fastdfs

   创建trackerd数据、日志目录
          [root@fastdfs2 fdfs]# mkdir -p /data/fastdfs

   启动trackerd
          [root@fastdfs2 fdfs]# /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart

可以查看日志:/data/fastdfs/logs/trackerd.log,来判断trackerd是否正常启动起来。

配置并启动storaged
修改storage.conf
[root@fastdfs2 fdfs]# cd /etc/fdfs/

          [root@fastdfs2 fdfs]# vi storage.conf

          base_path=/home/yuqing/fastdfs改为:base_path=/data/fastdfs

          store_path0=/home/yuqing/fastdfs改为:store_path0=/data/fastdfs/storage

          tracker_server=192.168.209.121:22122改为:tracker_server=192.168.1.207:22122,这个ip改成自己的

   创建storaged数据、日志目录
          [root@fastdfs2 fdfs]# mkdir -p /data/fastdfs/storage

   启动storaged
          [root@fastdfs2 fdfs]# /usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart

可以查看日志:/data/fastdfs/logs/storaged.log来判断storaged是否正常启动起来。

防火墙开端口
不开可能访问不了

nginx访问的端口
firewall-cmd --zone=public --add-port=80/tcp --permanent   (--permanent永久生效,没有此参数重启后失效)
tracker_server端口
firewall-cmd --zone=public --add-port=22122/tcp --permanent   
firewall-cmd --zone=public --add-port=23000/tcp --permanent  
firewall-cmd --reload

FastDFS 和nginx整合
fastdfs-nginx-module安装
解压

             [root@fastdfs2 00]# cd /opt

             [root@fastdfs2 opt]# unzip -o fastdfs-nginx-module-master.zip -d /usr/local

      拷贝配置文件

             [root@fastdfs2 opt]# cd /usr/local/fastdfs-nginx-module-master/src

             [root@fastdfs2 src]# cp mod_fastdfs.conf /etc/fdfs/

      编辑配置文件

             [root@fastdfs2 src]# cd /etc/fdfs/

             [root@fastdfs2 fdfs]# vi mod_fastdfs.conf

             base_path=/tmp改成:base_path=/data/fastdfs

             tracker_server=tracker:22122改成:tracker_server=192.168.1.207:22122

             url_have_group_name = false改成:url_have_group_name = true;#url中包含group名称

             store_path0=/home/yuqing/fastdfs改成:store_path0=/data/fastdfs/storage

nginx安装
nginx依赖包安装

         [root@fastdfs2 fdfs]# cd /opt

         [root@fastdfs2 opt]# yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel
         
         去nginx.org下个稳定版的nginx
  解压nginx
         [root@fastdfs2 opt]# tar -zxvf nginx-1.13.12.tar.gz
  安装nginx并添加fastdfs模块

         [root@fastdfs2 opt]# cd nginx-1.13.12

         [root@fastdfs2 nginx-1.13.12]# ./configure --prefix=/usr/local/nginx --add-module=/usr/local/fastdfs-nginx-module-master/src

         [root@fastdfs2 nginx-1.13.12]# make

         [root@fastdfs2 nginx-1.13.12]# make install

  检查nginx模块

         [root@fastdfs2 nginx-1.13.12]# cd /usr/local/nginx/sbin/

         [root@fastdfs2 sbin]# ./nginx -V

  配置nginx配置文件

         [root@fastdfs2 sbin]# cd /usr/local/nginx/conf

         [root@fastdfs2 conf]# vi nginx-fdfs.conf

内容如下,ip注意改成自己的:

  events {
        use epoll;

    worker_connections  1024;
}
http {
    server {
        listen       80;
        server_name  192.168.1.207;

        location /group1/M00/{
                #root /home/FastDFS/fdfs_storage/data;
                ngx_fastdfs_module;
        }
    }
    server {
        listen 8888;
    server_name 192.168.1.207;
        location / {
            root   html;
            index  index.html index.htm;
        }
    }
}

启动nginx

   [root@fastdfs2 conf]# cd /usr/local/nginx/sbin/

   [root@fastdfs2 sbin]# ./nginx -c /usr/local/nginx/conf/nginx-fdfs.conf

   访问图片
          文件路径在上面的上传图片的测试代码中有输入,我们进行拼装下:

          http://192.168.1.207/group1/M00/00/00/wKgBz1salX-ATR4PAABHO7x65CM553.jpg

如果要给nginx加认证
nginx配置文件里加

location / { 
            auth_basic            "Basic Auth";
            auth_basic_user_file  /usr/local/nginx/conf/passwd; 
        }

yum -y install httpd 装htpasswd
运行htpasswd -c /usr/local/nginx/conf/passwd test 创建名为test用户文件命令
再输入两遍密码123 创建完毕
重启nginx
命令 ./nginx -s reload
此时访问服务器会要求用户名密码

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值