CentOS7安装fastdfs
程序员文章站
2022-07-12 20:19:27
...
CentOS7安装fastdfs
安装CentOS基本依赖:
yum -y install tcl lrzsz deltarpm zlib zlib-devel pcre pcre-devel gcc gcc-c++ openssl openssl-devel libevent libevent-devel perl unzip net-tools wget
所需安装包:
- fastdfs-5.11.tar.gz
- fastdfs-nginx-module-1.20.tar.gz
- libfastcommon-1.0.39.tar.gz
- nginx-1.15.8.tar.gz
1. 安装common
解压:
tar -zxvf libfastcommon-1.0.39.tar.gz
编译和安装:
cd libfastcommon-1.0.39 && ./make.sh && ./make.sh install
查看安装好以后的common文件:
cd /usr/lib && ll libfast*
2. 安装tracker服务
解压:
tar -zxvf fastdfs-5.11.tar.gz
mkdir -p /etc/fdfs
cp /development/fastdfs-5.11/conf/mime.types /etc/fdfs/
cp /development/fastdfs-5.11/conf/http.conf /etc/fdfs/
编译和安装:
cd fastdfs-5.11 && ./make.sh && ./make.sh install
查看安装好以后的dfs文件:
cd /usr/bin && ll fdfs*
cd /etc/fdfs && ll fdfs*
配置tracker.conf
vim /development/fastdfs-5.11/conf/tracker.conf
修改base_path
base_path=/development/fastdfs/tracker
新建相关目录
mkdir /development/fastdfs/tracker -p
mkdir /development/fastdfs/client -p
mkdir /development/fastdfs/storage -p
mkdir /development/fastdfs/tmp -p
mkdir /var/temp/nginx/client -p
启动服务
fdfs_trackerd /development/fastdfs-5.11/conf/tracker.conf
fdfs_trackerd /development/fastdfs-5.11/conf/tracker.conf stop
fdfs_trackerd /development/fastdfs-5.11/conf/tracker.conf restart
3. 安装storage服务
vim /development/fastdfs-5.11/conf/storage.conf
配置storage.conf
修改base_path,group_name,store_path0,tracker_server,bind_addr
group_name=source
base_path=/development/fastdfs/storage
store_path0=/development/fastdfs/storage
tracker_server=当前ip
启动服务
fdfs_storaged /development/fastdfs-5.11/conf/storage.conf
配置client测试上传
配置client.conf
vim /development/fastdfs-5.11/conf/client.conf
修改base_path,tracker_server
tracker_server=当前ip
base_path=/development/fastdfs/client
测试上传(不支持直接上传远端图片测试)
fdfs_test /development/fastdfs-5.11/conf/client.conf upload /development/test.jpg
注:如果测试上传不成功并且配置没问题,可以试着重启虚拟机再试
4. 将nginx和fastdfs结合起来
解压:
tar -xzvf fastdfs-nginx-module-1.20.tar.gz
修改配置文件:
vim /development/fastdfs-nginx-module-1.20/src/config
ngx_module_incs="/usr/include/fastdfs /usr/include/fastcommon"
CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon"
安装nginx
解压 :
tar -zxvf /development/nginx-1.15.8.tar.gz
配置nginx
cd /development/nginx-1.15.8
./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/usr/local/nginx/errors/error.log \
--http-log-path=/usr/local/nginx/logs/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=/development/fastdfs-nginx-module-1.20/src
编译安装
make && make install
配置fastdfs-nginx-module
vim /development/fastdfs-nginx-module-1.20/src/mod_fastdfs.conf
修改base_path,tracker_server,group_name,url_have_group_name,store_path0
base_path=/development/fastdfs
store_path0=/development/fastdfs/storage
tracker_server=当前ip:22122
group_name=source
url_have_group_name=true
mv /development/fastdfs-nginx-module-1.20/src/mod_fastdfs.conf /etc/fdfs
修改nginx主配置文件
mkdir /usr/local/nginx/conf/conf.d
mkdir /usr/local/nginx/logs
vim /usr/local/nginx/conf/nginx.conf
pid /usr/local/nginx/logs/nginx.pid;
include conf.d/*.conf;
增加fastdfs和nginx的配置文件
vim /usr/local/nginx/conf/conf.d/fastdfs-server.conf
server {
listen 9870;
server_name 192.168.160.182;
location /source/M00 {
ngx_fastdfs_module;
}
}
启动nginx
检测脚本是否配置正确
/usr/local/nginx/sbin/nginx -t