yum install gcc gcc-c++ automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel git -y
磁盘目录
说明 | 位置 |
---|---|
所有安装包 | /usr/local/src |
数据存储位置 | /usr/local/src |
mkdir /home/dfs #创建数据存储目录
cd /usr/local/src #切换到安装目录准备下载安装包
1.安装libfastcommon
git clone https://gitee.com/fastdfs100/libfastcommon.git
cd libfastcommon/
./make.sh && ./make.sh install
cd ..
2.安装FastDFS
git clone https://github.com/happyfish100/fastdfs.git --depth 1
或
git clone https://gitee.com/fastdfs100/fastdfs.git--depth 1
cd fastdfs/
./make.sh && ./make.sh install #编译安装
配置文件准备
cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf
cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf
cp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf #客户端文件,测试用
cp /usr/local/src/fastdfs/conf/http.conf /etc/fdfs/ #供nginx访问使用
cp /usr/local/src/fastdfs/conf/mime.types /etc/fdfs/ #供nginx访问使用
3.安装fastdfs-nginx-module
cd ..
git clone https://gitee.com/fastdfs100/fastdfs-nginx-module.git --depth 1
cp /usr/local/src/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs
4.安装Nginx
wget http://nginx.org/download/nginx-1.20.2.tar.gz
tar -zxvf nginx-1.20.2.tar.gz
cd nginx-1.20.2/
#编译并指定安装路径为 /usr/local/nginx
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_sub_module --with-http_gzip_static_module --with-pcre --add-module=/usr/local/src/fastdfs-nginx-module/src/
make && make install #编译安装
tracker配置
配置前先创建目录
mkdir -p /home/wzz/dfs/tracker/
mkdir -p /home/wzz/dfs/storage/
mkdir -p /home/wzz/dfs/client/
vim /etc/fdfs/tracker.conf
base_path= /home/wzz/dfs/tracker
storage配置
vim /etc/fdfs/storage.conf
内容如下:
store_path0 = /home/wzz/dfs/storage/
base_path= /home/wzz/dfs/storage/
tracker_server = 192.168.222.222:22122
tracker_server = 192.168.222.222:22122
client配置
vim /etc/fdfs/client.conf
base_path= /home/wzz/dfs/client/
tracker_server = 192.168.222.222:22122
tracker_server = 192.168.222.223:22122
配置Nginx访问
vim /etc/fdfs/mod_fastdfs.conf
和之前的保持一致就行了
tracker_server =192.168.222.222:22122
tracker_server =192.168.222.223:22122
group_name=wzz
url_have_group_name=true
store_path0 = /home/wzz/dfs/storage/
vim /usr/local/nginx/conf/nginx.conf
server {
listen 8888; ## 该端口为storage.conf中的http.server_port相同
server_name localhost;
location ~/group[0-9]/ {
ngx_fastdfs_module;
}
}
启动tracker
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf
关闭tracker
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf stop
重启tracker
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
启动storage
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf
关闭storage
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf stop
重启storage
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
启动Nginx
/usr/local/nginx/sbin/nginx