fastdfs-nginx-module-master/src/common.c, line: 163, load conf file “/etc/fdfs/mod_fastdfs.conf”

介绍


在配置fastdfs-nginx-module时,nginx启动8888端口,访问http://localhost:8888/group1/M00/00/00/CgOYSGGoR5qASNqzAANi9H7oGe4006.jpg 时无响应,查看nginx的error.log日志,发现报错 fastdfs-nginx-module-master/src/common.c, line: 163, load conf file “/etc/fdfs/mod_fastdfs.conf” fail, ret code: 2

2021-11-30 17:13:01] ERROR - file: shared_func.c, line: 1163, file /etc/fdfs/mod_fastdfs.conf not exist
[2021-11-30 17:13:01] ERROR - file: ../fastdfs-nginx-module-master/src/common.c, line: 163, load conf file "/etc/fdfs/mod_fastdfs.conf" fail, ret code: 2
[2021-11-30 17:13:01] INFO - file: ini_file_reader.c, line: 1349, func: checkInitDynamicContentArray, init_pthread_lock
[2021-11-30 17:13:01] INFO - file: ini_file_reader.c, line: 1384, func: checkAllocDynamicContentArray, alloc count: 8
[2021-11-30 17:13:01] ERROR - file: shared_func.c, line: 1163, file /etc/fdfs/mod_fastdfs.conf not exist
[2021-11-30 17:13:01] ERROR - file: ../fastdfs-nginx-module-master/src/common.c, line: 163, load conf file "/etc/fdfs/mod_fastdfs.conf" fail, ret code: 2
2021/11/30 17:13:01  128284#0: worker process 128288 exited with fatal code 2 and cannot be respawned
2021/11/30 17:13:01  128284#0: worker process 128286 exited with fatal code 2 and cannot be respawned

问题说明


fastdfs-nginx-module-master/src/common.c, line: 163, load conf file “/etc/fdfs/mod_fastdfs.conf” fail, ret code: 2
看内容就知道加载配置文件 /etc/fdfs/mod_fastdfs.conf 失败,出现这个报错的大概原因就是 /etc/fdfs 下面没有这个配置文件

报错原因


由于自己安装fastdfs时修改了安装路径/data/fdfs/,没有生成 /etc/dfs目录

解决方法


修改 fastdfs-nginx-module-master/src/config
把 DFDFS_MOD_CONF_FILENAME 的路径改成自定义的目录就可以了
我这里 改成了/data/fdfs/etc/fdfs/mod_fastdfs.conf,一定要先把 mod_fastdfs.conf 复制过去

vim fastdfs-nginx-module-master/src/config

ngx_addon_name=ngx_http_fastdfs_module

if test -n "${ngx_module_link}"; then
    ngx_module_type=HTTP
    ngx_module_name=$ngx_addon_name
    ngx_module_incs="/usr/include/fastdfs /usr/include/fastcommon/"
    ngx_module_libs="-lfastcommon -lfdfsclient"
    ngx_module_srcs="$ngx_addon_dir/ngx_http_fastdfs_module.c"
    ngx_module_deps=
    CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -DFDFS_MOD_CONF_FILENAME='\"/data/fdfs/etc/fdfs/mod_fastdfs.conf\"'"
    . auto/module
else
    HTTP_MODULES="$HTTP_MODULES ngx_http_fastdfs_module"
    NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_fastdfs_module.c"
    CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"
    CORE_LIBS="$CORE_LIBS -lfastcommon -lfdfsclient"
    CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -DFDFS_MOD_CONF_FILENAME='\"/data/fdfs/etc/fdfs/mod_fastdfs.conf\"'"
fi

重新编译nginx


./configure --prefix=/data/fdfsnginx --add-module=../fastdfs-nginx-module/src
make
make install

重启nginx


/data/fdfsnginx/sbin/nginx -c /data/fdfsnginx/conf/nginx.conf -s reload

版权声明:本文为作者原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

原创文章,作者:老C,如若转载,请注明出处:https://www.code404.icu/1465.html

发表评论

登录后才能评论