fastdfs-nginx-module安装

2017-12-12  本文已影响0人  howdyli

前提:已成功安装fastdfs, Fastdsf在centos7.2下的安装

参考:Centos7安装FastDFS+nginx module

fastdfs-nginx-module安装

安装工具

mkdir opt

cd  opt

yum -y  install pcre-devel opensslopenssl-devel

2.下载解压安装包

wget https://github.com/happyfish100/fastdfs-nginx-module/archive/master.zip

unzip master.zip

wget http://nginx.org/download/nginx-1.9.5.tar.gz

tar -zxv -f nginx-1.9.5.tar.gz

3.安装nginx

mv nginx-1.9.5 /usr/local/

cd /usr/local/nginx-1.9.5

./configure --add-module=/opt/fastdfs-nginx-module-master/src/--prefix=/usr/local/nginx --user=root--group=root--with-http_gzip_static_module --with-http_gunzip_module

make

make install

注:此处需要添加fastdfs-nginx-module的源码

4.配置mod_fastdfs.conf

cp /opt/fastdfs-nginx-module-master/src/mod_fastdfs.conf /etc/fdfs/

mkdir /data/ngx

vi /etc/fdfs/mod_fastdfs.conf

修改下面四个参数:

# the base path to store log files

base_path=/data/ngx

# FastDFS tracker_server

tracker_server=192.168.153.130:22122

# store_path#, based 0, if store_path0 notexists, it's value is base_path

# the paths must be exist

# must same as storage.conf

store_path0=/data/fdfs/storage

# if the url / uri including the group name

url_have_group_name= true

参见fastdfs上传成功,下载400错误解决办法

5.添加http.conf,mime.types到/etc/fdfs

cd /root/fdfs/fastdfs-5.11/conf

cphttp.confmime.types/etc/fdfs

注:/root/fdfs/fastdfs-5.11为fastdfs的下载解压文件目录

参考Centos7安装FastDFS+nginx module

6.修改nginx配置文件

vi /usr/local/nginx/conf/nginx.conf

配置内容如下:

location /group1/M00{

#root指向数据根目录,即storage的store_path

root/data/fdfs/storage;

ngx_fastdfs_module;

}

详细配置如下:

server {

listen80;

server_name 114.115.140.115;

#charset koi8-r;

#access_loglogs/host.access.logmain;

location /group1/M00 {

#root指向数据根目录,即storage的store_path

root /fastdfs/storage;

ngx_fastdfs_module;

}

error_page500 502 503 504/50x.html;

location = /50x.html {

roothtml;

}

}

创建/M00软连接

ln -s          /fastdfs/storage/data/fastdfs/storage/data/M00

启动:

/usr/local/nginx/sbin/nginx

验证:

curl http://localhost

查看错误信息

tail -f /usr/local/nginx/logs/error.log

重启:

/usr/local/nginx/sbin/nginx -s reload

8.测试

wgethttp://ip地址/group1/M00/00/00/wKiZglauvkmANC2wAAAAPpWmuhI171_big.txt

成功下载文件到当前文件夹

上一篇下一篇

猜你喜欢

热点阅读