centos8安装fastdfs和nginx

1.下载所需依赖库

[root@caochenlei ~]# yum install -y gcc gcc-c++ perl perl-devel openssl openssl-devel pcre pcre-devel zlib zlib-devel libevent libevent-devel


2.下载fastdfs-storage,并解压安装

wget
https://github.com/happyfish100/libfastcommon/archive/V1.0.43.tar.gz

tar -zxvf V1.0.43.tar.gz
cd ibfastcommon-1.0.43/
./make.sh 
./make.sh install
cd ..


3.下载fastdfs-tracker,并解压安装

wget https://github.com/happyfish100/fastdfs/archive/V6.06.tar.gz

tar -zxvf V6.06.tar.gz 
cd fastdfs-6.06/
./make.sh
./make.sh install
cd ..



4.创建fastdfs存储文件夹目录

cd /home/pro/work/fdfs
mkdir client
mkdir storage
mkdir tracker



5.创建fastdfs配置文件

cd /etc/fdfs/
cp  tracker.conf.sample tracker.conf
cp storage.conf.sample storage.conf
cp client.conf.sample client.conf



6.修改fastdfs配置文件

vim     tracker.conf
base_path=/home/pro/work/fdfs/tracker

vim storage.conf
base_path=/home/pro/work/fdfs/storage
store_path0 =/home/pro/work/fdfs/storage
tracker_server=192.168.1.106:22122

vim client.conf
base_path = /home/pro/work/fdfs/tracker
tracker_server = 192.168.1.106:22122


7.开启fastdfs服务

fdfs_trackerd  /etc/fdfs/tracker.conf
fdfs_storaged  /etc/fdfs/storage.conf



8.上传一个文件测试

fdfs_upload_file /etc/fdfs/client.conf tets.jpg



得到返回的特征码表示上传成功,且对应编组文件夹中找到对应上传的文件。
group1/M00/00/00/wKgBamLYOMWAOjv5ACBtqBt3eeY961.jpg


1.安装nginx依赖

yum install -y gcc gcc-c++ make libtool wget pcre pcre-devel zlib zlib-devel openssl openssl-devel


2.下载nginx和fastdfs-nginx-module,并解压。注意module只能在安装nginx时加载!

wget http://nginx.org/download/nginx-1.18.0.tar.gz
tar -zxvf nginx-1.18.0.tar.g
wget https://github.com/happyfish100/fastdfs-nginx-module/archive/V1.22.tar.gz
tar -zxvf V1.22.tar.gz

cd fastdfs-nginx-module-1.22/src/
pwd
/root/fastdfs-nginx-module-1.22/src



3.为nginx安装module

cd nginx-1.18.0
./configure  --add-module=/home/pro/fastdfs-nginx-module-1.22/src
make && make install



若安装失败,可能是缺少nginx运行依赖库,将缺少的库安装后再安装nginx、

4.将module包src里的配置文件拷贝并修改

cd /home/pro/fastdfs-nginx-module-1.22/src
cp mod_fastdfs.conf /etc/fdfs/
cd /etc/fdfs/

vim mod_fastdfs.conf
connect_timeout=10    //连接超时时间默认为2秒,修改为10秒
base_path=/home/pro/work/fdfs/tracker    //设为fdfs-tracker的工作文件夹
tracker_server=192.168.1.106:22122        //设为fdfs-tracker的ip
store_path0=/home/pro/work/fdfs/storage        //设为fdfs-storage的工作文件夹
url_have_group_name=true    //启用组名



5.把fastdfs-server中的配置文件拷贝,做nginx网络层作用

cd fastdfs-6.06/conf
cp http.conf  /etc/fdfs/
cp mime.types /etc/fdfs/



6.配置nginx配置文件,添加服务器配置信息

cd /usr/local/nginx/conf

vim nginx.conf

#gzip  on;
 server{
          listen      8888;        //ngxin端口号
          server_name 192.168.1.106;    //nginxip地址
          location ~ /group[1-9]/M0[0-9] {    //组名
              ngx_fastdfs_module;    //模组
  }
          error_page   500 502 503 504  /50x.html;    //错误页面
          location /50x.html {
                root   html;
            } 
 }


7.启动nginx服务

cd /usr/local/nginx/sbin
./nginx



8.测试nginx服务
在浏览器输入 192.168.1.106:8888,会显示nginx默认页面。
再次输入 192.168.1.106:8888/group1/M00/00/00/wKgBamLYOMWAOjv5ACBtqBt3eeY961.jpg 会显示刚刚上传的图片
 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值