FastDFS与Nginx 整合

FastDFS与Nginx 整合

1.安装FastDFS-Nginx-Module扩展

fastdfs-nginx-module可以重定向连接到源服务器取文件,避免客户端由于复制延迟的问题,出现错误

cd /usr/local/src
git clone https://github.com/happyfish100/fastdfs-nginx-module.git --depth 1
cp /usr/local/src/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs

2.安装Nginx

路径:/usr/local/src下

wget http://nginx.org/download/nginx-1.15.4.tar.gz #下载
tar -zxvf nginx-1.15.4.tar.gz  #解压
cd nginx-1.15.4/
./configure --add-module=/usr/local/src/fastdfs-nginx-module/src/  #进入nginx Nginx编译环境设置 添加fastdfs-nginx-module模块
make  #编译
make install #安装

没有wget的话需要安装

sudo apt install wget

安装不成功请看这里

3.修改配置

3.1 修改mod_fastdfs.conf

vim /etc/fdfs/mod_fastdfs.conf
#修改配置
base_path=/home/FastDFS  # 日志和文件的根目录 Storage
tracker_server=192.168.1.1:22122 # trackerker服务器IP和端口
url_have_group_name=true #url 中包含 group 名称
store_path0=/home/fastdfs/fdfs_storage #指定文件存储路径

3.2 修改nginx.conf

vim /usr/local/nginx/conf/nginx.conf #配置nginx.config

# Nginx中添加如下配置,Storage服务器和Tracker服务器都需要配置Nginx
server {
    listen       80;    # 该端口为storage.conf中的http.server_port相同
    server_name  localhost;
    location /group1/M00 {
    root /home/fastdfs/fdfs_storage/data;
        ngx_fastdfs_module;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
    root   html;
    }
}

4.启动nginx

/usr/local/nginx/sbin/nginx    # 自定义conf 可以通过 -c指定  如 ‐c /usr/local/nginx/conf/nginx‐fdfs.conf
发布了57 篇原创文章 · 获赞 52 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/qq_40495860/article/details/97681717