今天给 nginx 组合 fastdfs-nginx-module ,起初是一步一步来的。
先是在 nginx 目录下配置 fastdfs-nginx-module 的路径:
./configure --add-module=[fastdfs-nginx-module 路径]/src
然后是给 nginx 目录下的 objs/Makefile 文件中增加头文件目录:
ALL_INCS = -I src/core \
-I /usr/include/fastdfs \ # 增加的
-I /usr/include/fastcommon \ # 增加的
-I src/event \
-I src/event/modules \
接着就是在 nginx 目录下 make、 make install。无报错,一切正常。
然后是拷贝 nginx/conf/mime.types、fastdfs/conf/http.conf、fastdfs-nginx-module/src/mod_fastdfs.conf 这三个文件到 /etc/fdfs 目录下。根据实际情况修改 mod_fastdfs.conf 文件。
最后配置 nginx.conf 如下:
location /group1/M00 {
root /opt/YouGuan/fastDFS/storage/data;
ngx_fastdfs_module;
}
但是,页面仍不能直接访问图片。nginx 的错误日志中一直报:2019/05/05 22:24:53 [emerg] 67870#0: unknown directive "ngx_fastdfs_module" in /usr/local/nginx/conf/nginx.conf:70
。试了很多方法都没解决。
结果却是:没有重启 nginx 。记住,一定要重启 nginx,命令:systemctl restart nginx
。如果只是重新加载 nginx.conf 文件(nginx -s reload)是不管用的,不要问我为什么知道!
还不快抢沙发