FastDFS_v5.05安装配置,并且使用nginx 访问

FastDFS_v5.05安装配置

1、软件下载:

wget https://github.com/happyfish100/libfastcommon/archive/V1.0.7.tar.gz
wget http://jaist.dl.sourceforge.net/project/fastdfs/FastDFS%20Nginx%20Module%20Source%20Code/fastdfs-nginx-module_v1.16.tar.gz
wget https://github.com/happyfish100/fastdfs/archive/V5.05.tar.gz
wget http://nginx.org/download/nginx-1.8.0.tar.gz

2、libfastcommon安装:

cp V1.0.7.tar.gz /usr/local/
tar -zxvf V1.0.7.tar.gz
cd libfastcommon-1.0.7
./make.sh
./make.sh install

libfastcommon.so默认安装到了/usr/lib64/libfastcommon.so,而FastDFS主程序设置的lib目录是/usr/local/lib,所以设置软连接

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

3、安装FastDFS:

  1. 解压fastdfs 到 /user/local 目录:
tar -zxvf V5.05.tar.gz -C /usr/local
cd /usr/local/fastdfs-5.05/
./make.sh
./make.sh install
cd /etc/fdfs
  1. 配置文件设置:
cp tracker.conf.sample tracker.conf
cp storage.conf.sample storage.conf
cp client.conf.sample client.conf
  1. tracker.conf配置中要修改的几个项:
bind_addr=
port=22122
base_path=/home/fastdfs/tracker
http.server_port=80
  1. storage.conf配置中要修改的几个项:
group_name=group1
bind_addr=
port=23000
base_path=/home/fastdfs/storage
store_path0=/home/fastdfs/storage
tracker_server=10.255.0.227:22122
http.server_port=80
  1. 创建文件夹
mkdir -p /home/fastdfs/tracker
mkdir -p /home/fastdfs/storage
  1. 启动
启动tracker storage.conf
fdfs_trackerd /etc/fdfs/tracker.conf
fdfs_storaged /etc/fdfs/storage.conf

4、安装nginx插件:

  1. 安装
tar -zxvf fastdfs-nginx-module_v1.16.tar.gz
cd fastdfs-nginx-module/src/
  1. 修改config文件
vim config
修改如下配置,我这里原来是
CORE_INCS="$CORE_INCS /usr/local/include/fastdfs /usr/local/include/fastcommon/"
改成
CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"
  1. 修改mod_fastdfs.conf后移动配置文件到/etc/fdfs
## 编辑文件
vim mod_fastdfs.conf

## 修改内容
group_name=group1
tracker_server=10.255.0.227:22122
store_path0=/home/fastdfs/storage
base_path=/home/fastdfs/storage
url_have_group_name = true
## 移动
cp  mod_fastdfs.conf /etc/fdfs
  1. 将fastdfs-5.05目录下两个文件复制到/etc/fdfs/
cp /usr/local/fastdfs-5.05/conf/http.conf /etc/fdfs/
cp /usr/local/fastdfs-5.05/conf/mime.types /etc/fdfs/

5、nginx安装:

  1. 解压nginx
tar -zxvf nginx-1.8.0.tar.gz
cd nginx-1.8.0
  1. 配置编译参数
./configure --prefix=/usr/local/nginx_fdfs --add-module=/root/soft-package/fastdfs-nginx-module/src
  1. 编译并且安装
make & make install
  1. 配置nginx.config
cd /usr/local/nginx/conf
vim nginx.conf
## 配置如下 (添加一个location)
#FASTDFS
location ~/group([0-9]){
	ngx_fastdfs_module;
}
  1. 启动nginx
cd/usr/local/nginx_fdfs/sbin
./nginx

6、测试文件上传:

touch test.txt # 创建一个测试文件
ls -a >> test.txt # 输入一些文本
/usr/bin/fdfs_upload_file /etc/fdfs/storage.conf test.txt # 上传
控制台输入:(group1/M00/00/00/Cv8A418vYZeAcbkSAAABN0RynWk086.txt)

访问: http://116.85.25.106/group1/M00/00/00/Cv8A418vYZeAcbkSAAABN0RynWk086.txt
# Linux   Fastdfs  

评论

公众号:mumuser

企鹅群:932154986

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×