安装fastdfs
- 安装编译工具gcc/pcre /perl …
yum -y groupinstall 'Development Tools'
yum -y install wget
- 按照顺序依次上传文件到linux,解压,然后进入到解压目录下,找到make/make.sh按照顺序进行编译安装
- cp /usr/lib64/libfastcommon.so /usr/lib/ 将libfastcommon.so复制到 /usr/lib/
- cp /opt/FastDFS/conf/* /etc/fdfs/ 将安装目录下的配置文件全部复制到etc/fsfs方便管理
- 创建fast存储数据和文件的目录
[root@localhost ~]# mkdir /opt/fastdfs/
[root@localhost ~]# mkdir /opt/fastdfs/fdfs_storage/ - 将上述路经配置到下列文件中
[root@localhost conf]# vim /etc/fdfs/tracker.conf
[root@localhost conf]# vim /etc/fdfs/storage.conf (需要更改三个地方)
- 更改里面的base_path (因为里面有作者的标签)
- dfs_storage=“/opt/fastdfs/fdfs_storage”
- tracker_server=192.168.3.202:22122
-
vim /etc/init.d/fdfs_storaged 我们发现服务启动时是从/usr/local/bin/下去找*sh,所以我们需要将fast的启动和重启命令的脚本文件复制到相应目录
[root@localhost FastDFS]# cp /opt/FastDFS/restart.sh /usr/local/bin/
[root@localhost FastDFS]# cp /opt/FastDFS/stop.sh /usr/local/bin/
-
将启动脚本加入linux服务
[root@localhost FastDFS]# chkconfig --add /etc/init.d/fdfs_storaged
[root@localhost FastDFS]# chkconfig --add /etc/init.d/fdfs_trackerd -
更改解压目录里面的storage.conf和trackver.conf的 base_path="/opt/fdfs"
[root@localhost conf]# vim storage.conf
[root@localhost conf]# vim tracker.conf
[root@localhost conf]# pwd
/opt/FastDFS/conf
-
启动:service fdfs_trackerd start
-报错: -
find / -name fdfs_trackerd 发现我的文件是在/usr/bin/fdfs_trackerd,于是换个地方
-
cp /usr/bin/fdfs_trackerd /usr/local/bin/fdfs_trackerd
-
cp /usr/bin/fdfs_storaged /usr/local/bin/fdfs_storaged
-
再次运行 service fdfs_trackerd start
-
service fdfs_storaged start
-
测试一下
/usr/bin/fdfs_test /etc/fdfs/client.conf upload /home/lmj/tangyan.jpg
报错了:
[2019-08-30 09:57:19] ERROR - file: ../client/client_func.c, line: 257, "/home/yuqing/fastdfs" can't be accessed, error info: No such file or directory
解决如下:
vim /etc/fdfs/client.conf
将base_path改了,tracker的ip也要改
运行成功:
安装fastdfs和nginx整合的插件
- vim mod_fastdfs.conf
store_path0=/opt/fastdfs/fdfs_storage
-cp mod_fastdfs.conf /etc/fdfs/ 将mod_fastdfs.conf拷贝至/etc/fdfs/下统一管理配置文件
-进入如下目录, 运行下面命令将添加到ngignx中
出现这个代表该步成功:
- mkdir -p /var/temp/nginx/client 创建临时的目录
- vim/opt/nginx-1.12.2/conf/nginx.conf 编辑配置文件,完成http反向代理(请求转发)
安装nginx
安装可参考菜鸟教程
启动nginx:
/usr/local/webserver/nginx/sbin/nginx
-
重启nginx
/usr/local/webserver/nginx/sbin/nginx -s reload -
nginx安装目录的配置文件
vim /opt/nginx-1.12.2/conf -
nginx系统目录的配置文件
vim /opt/nginx-1.12.2/conf/nginx.conf
报错:
- unknown directive “ngx_fastdfs_module” in /usr/local/webserver/nginx/conf/nginx.conf
解决:
./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
–add-module=/opt/fastdfs-nginx-module/src
然后
make && make install
又报了一个这个错误
/opt/fastdfs-nginx-module/src/common.c:21:25: fatal error: fdfs_define.h: No such file or directory
在common.c里面出现了变量类型不匹配,还有方法名找不到的错误,谷歌一番之后找不到类似的问题,出现一般的问题的英文common.c的依赖文件找不到,但是我的已经安装完成,可以进行依赖,但是出现了变量类型不匹配的问题
-
vim /opt/fastdfs-nginx-module/src/config
(原来是/usr/local/include) -
再次在nginx下执行命令
./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 --add-module=/opt/fastdfs-nginx-module/src
make && make install
经过了上述步骤,还是不行,于是参考了这篇文章,终于找到了思路:
https://blog.csdn.net/qq_34898847/article/details/82258453
[root@localhost nginx-1.12.2]# ./configure --add-module=/opt/fastdfs-nginx-module
出现如下报错的解决方案
./configure: error: no /opt/fastdfs-nginx-module/config was found
- cp config …
再次./configure
make,make install
报错:
No rule to make target `/opt/fastdfs-nginx-module/ngx_http_fastdfs_module.c', needed by `objs/addon/fastdfs-nginx-module/ngx_http_fastdfs_module.o'. Stop.
- 解决方案 cp /usr/lib64/libfdfsclient.so /usr/lib/
- cd libfastcommon-1.0.7/ 然后执行./make.sh 然后 ./make.sh install
./configure --add-module=/opt/fastdfs-nginx-module/src 注意后面的src
#include “fdfs_define.h”
[root@follow1 nginx-1.12.2]# vim /opt/fastdfs-nginx-module/src/common.c
从头再来
删掉这两个文件()里面的local
测试一下:
/usr/bin/fdfs_test /etc/fdfs/client.conf upload /home/lmj/tangyan.jpg
192.168.0.197
安装Fastfdsf的配置文件有:
- vim /usr/local/FastDFS/conf/storage.conf
- vim /etc/fdfs/storage.conf
- vim /etc/fdfs/client.conf
192.168.0.197
重启:
service fdfs_storaged start
service fdfs_trackerd start
/usr/bin/fdfs_test /etc/fdfs/client.conf upload /home/lmj/tangyan.jpg
/usr/local/nginx/sbin/nginx
http://192.168.3.203/group1/M00/00/00/wKgDy11pSfqAU-8yAALLQJh-5qk800_big.jpg
location /group1/M00/ {
ngx_fastdfs_module;
}