ubuntu18安装fastdfs nginx

  1. 背景:ubuntu-18.04,nginx-1.14,fastdfs-6.0.4,fastdfs-nginx-module-1.22,libfastcommon-1.0.42
  2. 步骤
    (1)安装libfastcommon
wget https://github.com/happyfish100/libfastcommon/archive/V1.0.42.tar.gz
tar -zxvf V1.0.42.tar.gz
cd libfastcommon-1.0.42
./make.sh
./make.sh install

创建软连接

ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so
 ln -s /usr/lib64/libfdfsclient.so /usr/local/lib/libfdfsclient.so

如果make出错,尝试以下命令:

 apt-get update
 apt-get install build-essential
 apt-get install libtool
 apt-get install openssl
 apt-get install libpcre3 libpcre3-dev
apt-get install zlib1g-dev 

(2)安装FastDFS

wget https://github.com/happyfish100/fastdfs/archive/V6.04.tar.gz
tar -zxvf V6.04.tar.gz
 cd fastdfs-6.04/
 ./make.sh
 ./make.sh install

(3)修改配置文件

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

3.1 配置storage.conf

vim storage.conf

base_path=/home/yuqing/fastdfs 为存储路径,可修改,不存在要创建
store_path0与上面一样
tracker_server= 设置为自己电脑ip

3.2 配置tracker.conf
tracker_server 设置为自己电脑ip
base_path=/home/yuqing/fastdfs 同上

3.3 配置client.conf
base_path 与上面一样
tracker_server 设置为自己电脑ip

  1. 启动服务程序
  /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
  /usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
  1. 测试
    5.1 查看Storage和Tracker是否在通信
 /usr/bin/fdfs_monitor /etc/fdfs/storage.conf

出现active为正常

5.2 文件上传测试

/usr/bin/fdfs_upload_file /etc/fdfs/client.conf test.jpeg

6.nginx相关
由于本机已经安装nginx,所以不再安装。接下来安装fastdfs-nginx-module。关于如何在不卸载nginx情况下安装第三方模块,请参考另一篇文章。
需要说明的是,fastdfs-nginx-module版本是1.22,一开始用的版本较低,编译时出现了错误,看网上教程说改src下config文件,改了之后报错:
error: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘FDFSStorePathInfo
更换1.22版本后无任何问题出现,顺利将nginx编译成功。

wget https://github.com/happyfish100/fastdfs-nginx-module/archive/V1.22.tar.gz

client.conf tracker.conf storage.conf 中端口要一致,与nginx监听端口相同
复制fastdfs安装包下conf文件夹中的http.conf mime.types到/etc/fdfs
复制fastdfs-nginx-module安装包下src文件夹中mod_fastdfs.conf到/etc/fdfs

vim mod_fastdfs.conf

tracker_server 与上面一致
url_have_group_name设置为true
store_path0与上面一致
nginx配置参考如下:

server {
            listen       8888;
            server_name  192.168.0.88;
            location ~/group([0-9])/M00 {
                #alias  /home/yuqing/fastdfs/data;
                ngx_fastdfs_module;
            }
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
            root   html;
            }
        }

重启nginx,上传文件测试,不要用上传过的文件测试,访问不到,会返回400

fdfs_monitor /etc/fdfs/client.conf

fdfs_monitor /etc/fdfs/client.conf delete group2 47.101.xx
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值