linux系统FastDFS图片服务器搭建

作业一

FastDFS安装(保证网络可用)

1.安装编译环境

yum install git gcc gcc-c++ make automake vim wget libevent -y

2…安装libfastcommon 基础

mkdir  /opt/software/fastdfs -p
cd  /opt/software/fastdfs
git clone https://github.com/happyfish100/libfastcommon.git --depth 1
cd libfastcommon/ 
./make.sh && ./make.sh install 

3.安装FastDFS

cd  /opt/software/fastdfs
wget https://github.com/happyfish100/fastdfs/archive/V5.11.tar.gz 
tar -zxvf V5.11.tar.gz
cd fastdfs-5.11 
./make.sh && ./make.sh install 

#配置文件准备 
cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf 
cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf 
cp /etc/fdfs/client.conf.sample  /etc/fdfs/client.conf   
cp /opt/software/fastdfs/fastdfs-5.11/conf/http.conf  /etc/fdfs 
cp /opt/software/fastdfs/fastdfs-5.11/conf/mime.types  /etc/fdfs

vi /etc/fdfs/tracker.conf 
#需要修改的内容如下 
port=22122   
base_path=/home/fastdfs

vi /etc/fdfs/storage.conf
#需要修改的内容如下 
port=23000   
base_path=/home/fastdfs  # 数据和日志文件存储根目录 
store_path0=/home/fastdfs  # 第一个存储目录 
tracker_server=192.168.70.129:22122   
# http访问文件的端口(默认8888,看情况修改,和nginx中保持一致) 
http.server_port=8888 

4.启动

mkdir /home/fastdfs  -p 

/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart 

查看所有运行的端口

netstat -ntlp

5.测试上传

vi /etc/fdfs/client.conf

#需要修改的内容如下 

base_path=/home/fastdfs 
#tracker服务器IP和端口 
tracker_server=192.168.70.129:22122   

#保存后测试,返回ID表示成功 如:group1/M00/00/00/xxx.png

/usr/bin/fdfs_upload_file /etc/fdfs/client.conf /opt/software/fastdfs/1.png 

在这里插入图片描述

6.安装fastdfs-nginx-module

cd /opt/software/fastdfs/

下载

wget https://github.com/happyfish100/fastdfs-nginx-module/archive/V1.20.tar.gz
解压
tar -xvf V1.20.tar.gz

cd fastdfs-nginx-module-1.20/src 
vi config 
修改第5 行 和 15 行 修改成 
ngx_module_incs="/usr/include/fastdfs /usr/include/fastcommon/" CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"

cp mod_fastdfs.conf /etc/fdfs/

vi /etc/fdfs/mod_fastdfs.conf 
#需要修改的内容如下 
tracker_server=192.168.70.129:22122   
url_have_group_name=true 
store_path0=/home/fastdfs


mkdir -p /var/temp/nginx/client

  1. 安装nginx

    cd  /opt/software/fastdfs
    wget http://nginx.org/download/nginx-1.15.6.tar.gz 
    tar -zxvf nginx-1.15.6.tar.gz 
    cd nginx-1.15.6/
    yum -y install pcre-devel openssl openssl-devel 
    
    添加fastdfs-nginx-module模块
     ./configure  --add-module=/opt/software/fastdfs/fastdfs-nginx-module-1.20/src 
     
     编译安装 
     make && make install 
     查看模块是否安装上 
     /usr/local/nginx/sbin/nginx -V
     
     vi /usr/local/nginx/conf/nginx.conf
     #添加如下配置 
     server {       
    
     listen       8888;        
     server_name  localhost;       
     location ~/group[0-9]/ {           
            ngx_fastdfs_module;       
       } 
     }
     
     /usr/local/nginx/sbin/nginx 
    
    

    测试下载

    systemctl stop firewalld

    /usr/bin/fdfs_upload_file /etc/fdfs/client.conf /opt/software/fastdfs/1.png

    http://192.168.70.129:8888/group1/M00/00/00/wKhGgV8I8hOABgNpAAEbEVD9Lgw432.png

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值