fdfs文件服务器安装 及 整合nginx

本文详细介绍了如何在Linux环境下安装配置Nginx和FastDFS,包括依赖安装、配置文件调整、服务启动及测试过程,确保图片等文件的高效上传与访问。

nginx

下载:wget wget http://nginx.org/download/nginx-1.16.0.tar.gz

tar -zxvf nginx-1.16.0.tar.gz

  1. 进入解压目录中,在编译安装之前,需要安装两个依赖:

yum -y install pcre-devel

yum -y install openssl openssl-devel

./configure

make && make install

配置环境变量:

/etc/profile PATH=/usr/local/nginx/sbin:$PATH

source /etc/profile

error1:
在这里插入图片描述
ans:
yum -y install gcc gcc-c++ kernel-devel
error2:
D:\youdaoNote\sina2563676830\98d50b2000cb4c41a64e9f7dfe0c93e5\clipboard.png
ans:yum -y install gcc automake autoconf libtool make

error3:没有访问文件权
在这里插入图片描述
ans:调整nginx的使用用户为root,因为fdfs安装时用的root

fdfs文件服务器

  • wget https://github.com/happyfish100/libfastcommon/archive/V1.0.39.tar.gz -SO libfastcommon.tar.gz

  • wget https://github.com/happyfish100/fastdfs/archive/V5.11.tar.gz -SO fastdfs.tar.gz

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

解压:
tar -zxvf *.tar.gz

安装libfastcommon:

cd libfastcommon

./make.sh

./make.sh install

安装fastdfs:

cd …/fastdfs

./make.sh && ./make.sh install

程序安装在/usr/bin/下面,配置文件在/etc/fdfs/下面,且为模块,需要从fastdfs包移动到对应的目录下,移动fastdfs到/etc/fdfs/目录下面
cp /home/zwd/sofaware/fastdfs-5.11/conf/* /etc/fdfs

调整配置:
  1. 调整跟踪服务器配置文件: tracker.conf
#跟踪服务器端口
port=22122
#数据和文件的保存路径
base_path=/home/zwd/fastdfs
#http服务端口
http.server_port=9270
  1. 调整存储服务器配置文件:storage.conf
#存储服务器端口
port=23000
#存储文件和日志地址
base_path=/home/zwd/fastdfs
# store_path#, based 0, if store_path0 not exists, it's value is base_path
# the paths must be exist 
store_path0=/home/zwd/fastdfs
#tracker服务器,虽然是同一台机器上,但是不能写127.0.0.1。这项配置可以出现一次或多次
tracker_server=192.168.1.35:22122
#http服务端口,和nginx的监听端口一致
http.server_port=80
  1. 编辑客户端配置文件:client.conf
#客户端文件和日志地址
base_path=/home/zwd/fastdfs
#tracker服务器,虽然是同一台机器上,但是不能写127.0.0.1。这项配置可以出现一次或多次
tracker_server=192.168.1.35:22122
#tracker的 http服务端口
http.tracker_server_port=9270
  1. 调整http.conf
#调整路径正确
http.anti_steal.token_check_fail=/etc/fdfs/anti-steal.jpg
http.mime_types_filename=/etc/fdfs/mime.types
  1. 新建文件夹 mkdir /home/zwd/fastdfs

    启动tracker和storage

    service fdfs_trackerd start

    service fdfs_storaged start

  2. 通过monitor来查看storage是否成功绑定:

fdfs_monitor /etc/fdfs/storage.conf
C:\Users\36548\AppData\Roaming\Typora\typora-user-images\image-20200202210205224.png
7. 测试:

fdfs_test /etc/fdfs/client.conf upload /home/zwd/Desktop/111.png
C:\Users\36548\AppData\Roaming\Typora\typora-user-images\image-20200202211405441.png
调整nginx配置:
在这里插入图片描述
访问成功:在这里插入图片描述

fdfs整合nginx:

到下载的nginx源代码包中间,将fastdfs-nginx-module 集成到nginx配置中

./configure --add-module=/home/zwd/sofaware/fastdfs-nginx-module-1.20/src

执行 make && make install
在这里插入图片描述
移动fastdfs-nginx-module-1.20/src/mod_fastdfs.conf 到/etc/fdfs/下

调整/etc/fdfs/mod_fastdfs.conf

# the base path to store log files
base_path=/home/zwd/fastdfs
# 跟踪服务器
tracker_server=192.168.35.1:22122

store_path0=/home/zwd/fastdfs

测试:
C:\Users\36548\AppData\Roaming\Typora\typora-user-images\image-20200202225131599.png
在这里插入图片描述

结合代码测试:
C:\Users\36548\AppData\Roaming\Typora\typora-user-images\image-20200202230857871.png
在这里插入图片描述

可能存在的问题:

  1. fastdfs-nginx-module报错:fdfs_define.h:15:27: 致命错误:~/sofaware/fdfs-package/fastdfs-nginx-module-1.20/src/config:没有那个文件或目录

     调整模块:用绝对路径,不要用相对路径
    
  2. ./configure: error: the HTTP rewrite module requires the PCRE library.

     安装pcre-devel解决问题
     
     yum -y install pcre-devel
    
  3. 错误提示:

/configure: error: the HTTP cache module requires md5 functions

from OpenSSL library.  You can either disable the module by using

--without-http-cache option, or install the OpenSSL library into the system,

or build the OpenSSL library statically from the source with nginx by using

--with-http_ssl_module --with-openssl=<path> options.
解决办法:

yum -y install openssl openssl-devel
  1. error: the HTTP XSLT module requires the libxml2/libxslt

     解决方案:yum -y install libxml2 libxml2-dev 	yum -y install libxslt-d
    
  2. error: the HTTP image filter module requires the GD library

     解决方案:yum -y install gd-devel
    
  3. error: perl module ExtUtils::Embed is required

     解决方案:yum -y install perl-devel perl-ExtUtils-Embed
    
  4. error: the Google perftools module requires the Google perftools

     解决方案:yum install gperftools
    
  5. warning: the “–with-ipv6” option is deprecated

     解决方案:删除./configure 中的 --with-ipv6
    
  6. error:/usr/include/fastdfs/fdfs_define.h:15:27: fatal error: common_define.h: No such file or directory #include “common_define.h”

    解决方案:
    
    调整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/"
    
  7. error:"/etc/nginx/modules/ngx_http_image_filter_module.so" failed (/etc/nginx/modules/ngx_http_image_filter_module.so: cannot open shared object file: No such file or dire

    解决方案:nginx -V  检查moudles是否加入到nginx参数中
    
  8. error:ERROR - file: …/common/fdfs_http_shared.c, line: 148, param “http.mime_types_filename” not exist or is empty

    解决方案:复制 fastdfs-nginx-module 源码中的配置文件到/etc/fdfs 目录, 并修改
    
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值