1.系统环境和文件准备
- a. virtural box创建的centos7虚拟机
- 虚拟机创建需要使用桥接模式(根据需要选择),桥接模式类似同一个局域网内的其他计算机,会单独再分配一个IP,同局域网可访问,主机与虚拟机可互ping;NAT模式则在同一个局域网内无法访问到,虚拟机仅能通过主机与外界进行通信;主机模式则只能是主机与虚拟机通信。另外需安装openssl服务,用于xshell和xftp链接。
- b. 安装包文件
2. 基础配置与服务启动
cd /home/tar
yum -y install libevent
yum -y install zlib-devel pcre pcre-devel gcc gcc-c++ openssl openssl-devel libevent libevent-devel perl unzip net-tools wget ## nginix依赖
cd fastDFS/
## 安装 libfastcommlib 对应库
tar -zxvf libfastcommon-1.0.7.tar.gz
cd libfastcommon-1.0.7
./make.sh
./make.sh install
# 复制/usr/lib64/libfastcommon.so到/usr/lib/下
cd /usr/lib64
cp libfastcommon.so /usr/lib
# 安装fastDFS
cd /home/tar/fastDFS
tar -zxvf fastdfs-5.05.tar.gz
cd fastdfs-5.05
./make.sh
./make.sh install
# 配置、创建一些文件夹、启动服务
[root@localhost fdfs]# mkdir /fastdfs/tracker -p
[root@localhost fdfs]# mkdir /fastdfs/storage -p
[root@localhost fdfs]# mkdir /fastdfs/client -p
[root@localhost fdfs]# mkdir /fastdfs/tmp -p
cd conf
cp * /etc/fdfs/
cd /etc/fdfs/
----- # 配置tracker
vim /etc/fdfs/tracker.conf
# the base path to store data and log files
# base_path=/home/yuqing/fastdfs
base_path=/fastdfs/tracker # 保存退出
-----《《
---- 配置storage
vim /etc/fdfs/storage.conf
# and storage_ids.conf must be configed correctly.
group_name=pan
# the paths must be exist
# store_path0=/home/yuqing/fastdfs
store_path0=/fastdfs/storage
# the base path to store data and log files
#base_path=/home/yuqing/fastdfs
base_path=/fastdfs/storage
#tracker_server=192.168.209.121:22122
tracker_server=192.168.0.104:22122
----《《
---- 配置client
# the base path to store log files
# base_path=/home/yuqing/fastdfs
base_path=/fastdfs/client
# tracker_server can ocur more than once, and tracker_server format is
# "host:port", host can be hostname or ip address
tracker_server=192.168.0.104:22122
----《《
---- 配置 fastdfs与nginx的桥梁模块
cd /home/tar/fastDFS/
tar -zxvf fastdfs-nginx-module_v1.16.tar.gz
cd /home/tar/fastDFS/fastdfs-nginx-module/src
vim config
CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"
CORE_LIBS="$CORE_LIBS -L/usr/lib -lfastcommon -lfdfsclient" ## 删除其中的local
----《《
---- # 解压nginx包
cd /home/tar
tar -zxvf nginx-1.12.0.tar.gz
## 修改上传的配置文件中的fastdfs.txt的--add-module 如下:对应
--add-module=/home/tar/fastDFS/fastdfs-nginx-module/src
## 复制fastdfs.txt中的命令,执行
## 执行完后再执行make命令
make
make install
cd /home/tar/fastDFS/fastdfs-nginx-module/src /etc/fdfs
cp mod_fastdfs.conf /etc/fdfs
----- 《《
## 修改/etc/fdfs/mode_fastdfs.conf
vim /etc/fdfs/mode_fastdfs.conf
---- 修改如下
# the base path to store log files
base_path=/fastdfs/tmp
# valid only when load_fdfs_parameters_from_tracker is true
tracker_server=192.168.0.104:22122
# the group name of the local storage server
group_name=pan
# default value is false
url_have_group_name = true
# the paths must be exist
# must same as storage.conf
store_path0=/fastdfs/storage
#store_path1=/home/yuqing/fastdfs1
---- 《《
----- # 修改nginx.conf文件
vim /usr/local/nginx/conf/nginx.conf
#添加如下
server {
listen 88;
server_name 192.168.0.104;
location /pan/M00 {
ngx_fastdfs_moddule
}
}
## 测试:
cd /usr/local/nginx/sbin/
./nginx -t ## 执行结果可以看下图(测试nginx.conf是否配置成功)。
./nginx ## 启动nginx
----- 《《
# 启动状态查看
netstat -unltp|grep fdfs
## 各个服务启动命令如下
cd /usr/bin
fdfs_trackerd /etc/fdfs/tracker.conf # tracker启动 fdfs_trackerd /etc/fdfs/tracker.conf restart # 重启
fdfs_storaged /etc/fdfs/storage.conf # storage启动
fdfs_test /etc/fdfs/client.conf upload /home/1.png # client服务测试
安装完libfastcommonlib
安装完fastDFS
部分fastDFS配置文件
配置1
配置2
配置3
storage和tracker服务启动
client服务测试
复制fastdfs.txt中的命令,执行如下:
执行make命令如下图所示:
nginx安装完成
配置nginx.conf如下
测试nginx.conf是否配置成功
启动nginx