FastDFS 6.11.0 单机环境配置测试

1.软件信息

fastdfs-6.11.0.zip

fastdfs-nginx-module-1.24.zip

libfastcommon-1.0.71.zip

libserverframe-1.2.1.zip

nginx-1.24.0.tar.gz

 

源码地址:https://github.com/happyfish100

 

2.安装libfastcommon

unzip -o libfastcommon-1.0.71.zip -d /usr/local/

cd /usr/local/libfastcommon-1.0.71/

./make.sh

./make.sh  install

 

3.安装libserverframe

注意:在安装fastdfsv6.09以上版本时,需要首先安装libserverframe,否则在编译fastdfs时会提示以下错误:

In file included from ../common/fdfs_global.c:21:0:

../common/fdfs_global.h:17:26: 致命错误:sf/sf_global.h:没有那个文件或目录

 #include "sf/sf_global.h"

 

unzip -o libserverframe-1.2.1.zip -d /usr/local/

cd /usr/local/libserverframe-1.2.1/

./make.sh

./make.sh  install

 

4.安装fastdfs

unzip -o fastdfs-6.11.0.zip -d /usr/local/

cd /usr/local/fastdfs-6.11.0/

./make.sh

./make.sh  install

4.1.配置tracker服务

(1)修改配置文件

cd /etc/fdfs/

vi tracker.conf

 

base_path = /opt/fastdfs/tracker

 

mkdir -p /opt/fastdfs/tracker

 

(2)启动服务

fdfs_trackerd /etc/fdfs/tracker.conf

fdfs_trackerd /etc/fdfs/tracker.conf restart

 

(3)检查服务

ps aux | grep tracker

4.2.配置storage服务

(1)修改配置文件

cd /etc/fdfs/

vi storage.conf

 

base_path = /opt/fastdfs/storage/log

 

#这里还需要修改group_name,访问图片时,需要将当前的group_name作为前缀加到地址中。

group_name = qdsw

 

store_path0 = /opt/fastdfs/storage/file

 

# tracker服务的地址

tracker_server = 192.168.0.189:22122

 

 

mkdir -p /opt/fastdfs/storage/log

mkdir -p /opt/fastdfs/storage/file

 

(2)启动服务

fdfs_storaged /etc/fdfs/storage.conf

 

(3)检查服务

ps aux | grep storage

4.3.配置client

cd /etc/fdfs/

vi client.conf

 

base_path = /opt/fastdfs/client

 

# tracker服务的地址

tracker_server = 192.168.0.189:22122

 

 

mkdir -p /opt/fastdfs/client

 

 

4.4.测试

fdfs_test /etc/fdfs/client.conf upload /app/images/01.png

5.安装配置Nginx

5.1.解压fastdfs-nginx-module

unzip -o fastdfs-nginx-module-1.24.zip -d /usr/local/

 

cd /usr/local/fastdfs-nginx-module-1.24/

 

编辑配置文件,移除路径中的local

vi src/config

5.2.安装Nginx

 

yum -y install pcre pcre-devel

yum -y install openssl openssl-devel

 

tar -zxvf nginx-1.24.0.tar.gz -C /usr/local/

 

cd /usr/local/nginx-1.24.0/

 

./configure \

--prefix=/usr/local/nginx \

--pid-path=/var/run/nginx/nginx.pid \

--lock-path=/var/lock/nginx.lock \

--error-log-path=/var/log/nginx/error.log \

--http-log-path=/var/log/nginx/access.log \

--with-http_gzip_static_module \

--http-client-body-temp-path=/var/temp/nginx/client \

--http-proxy-temp-path=/var/temp/nginx/proxy \

--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \

--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \

--http-scgi-temp-path=/var/temp/nginx/scgi \

--with-http_ssl_module \

--add-module=/usr/local/fastdfs-nginx-module-1.24/src

 

 

make

 

make install

 

 

创建相关目录:

mkdir -p /var/temp/nginx/client

mkdir -p /var/temp/nginx/proxy

mkdir -p /var/temp/nginx/fastcgi

mkdir -p /var/temp/nginx/uwsgi

mkdir -p /var/temp/nginx/scgi

 

5.3.配置fastdfs

[root@sonar fdfs]# cp /usr/local/fastdfs-nginx-module-1.24/src/mod_fastdfs.conf .

[root@sonar fdfs]# pwd

/etc/fdfs

[root@sonar fdfs]# vi mod_fastdfs.conf

 

 

base_path=/opt/fastdfs/tmp

tracker_server=192.168.0.189:22122

group_name=qdsw

url_have_group_name = true

 

 

mkdir -p  /opt/fastdfs/tmp

 

 

5.4.配置Nginx

cd /usr/local/nginx

vi conf/nginx.conf

 

location /qdsw/M00 {

      ngx_fastdfs_module;

}

 

[root@sonar fdfs]# cp /usr/local/fastdfs-6.11.0/conf/http.conf .

[root@sonar fdfs]# cp /usr/local/fastdfs-6.11.0/conf/mime.types .

[root@sonar fdfs]# pwd

 

注意:启动Nginx服务,启动时如果fastdfs相关配置文件有问题,则会导致Nginx启动成功但是没有Worker线程。此时检查nginx的error日志文件查看报错信息。

 

5.5.测试访问

         访问提示404:

cd /etc/fdfs/

vi mod_fastdfs.conf

 

# must same as storage.conf

store_path0=/opt/fastdfs/storage/file

 

 

修改完成后,重启所有服务:

fdfs_trackerd /etc/fdfs/tracker.conf restart

fdfs_storaged /etc/fdfs/storage.conf restart

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

 

再次访问成功:

 

posted @ 2024-01-01 14:35  yshy  阅读(294)  评论(1编辑  收藏  举报