1、下载软件包
mkdir -p /opt/fastdfs cd /opt/fastdfs wget https://download.xinac.net/download/fastdfs/fastdfs-5.12.tar.gz wget https://download.xinac.net/download/fastdfs/fastdfs-nginx-module-1.22.tar.gz wget https://download.xinac.net/download/fastdfs/libfastcommon-1.0.39.tar.gz yum install git gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel wget vim -y # 创建数据存储目录 mkdir -p /home/fastdfs/storage/file mkdir -p /home/fastdfs/tracker
2、安装libfastcommon
cd /opt/fastdfs && tar -zxvf libfastcommon-1.0.39.tar.gz && cd libfastcommon-1.0.39 # 编译安装 ./make.sh && ./make.sh install ## 以下操作可选 #ln -sf /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so #ln -sf /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.so #ln -sf /usr/lib64/libfdfsclient.so /usr/local/lib/libfdfsclient.so #ln -sf /usr/lib64/libfdfsclient.so /usr/lib/libfdfsclient.so
3、安装FastDFS
cd /opt/fastdfs && tar -zxvf fastdfs-5.12.tar.gz && cd fastdfs-5.12 # 编译安装 ./make.sh && ./make.sh install # 配置文件准备 cp /opt/fastdfs/fastdfs-5.12/conf/* /etc/fdfs/
4、安装fastdfs-nginx-module
## 单台文件服务器可不安装 cd /opt/fastdfs && tar -zxvf fastdfs-nginx-module-1.22.tar.gz cp fastdfs-nginx-module-1.22/src/mod_fastdfs.conf /etc/fdfs/
5、安装nginx
## 单台文件服务器可不安装 fastdfs-nginx-module cd /opt/fastdfs && wget https://download.xinac.net/download/server/nginx/nginx-1.18.0.tar.gz tar -zxvf nginx-1.18.0.tar.gz && cd /opt/fastdfs/nginx-1.18.0 ./configure --user=nginx --group=nginx \ --prefix=/usr/local/nginx \ --conf-path=/etc/nginx/nginx.conf \ --error-log-path=/var/log/nginx/error.log \ --http-log-path=/var/log/nginx/access.log \ --pid-path=/var/run/nginx/nginx.pid \ --lock-path=/var/lock/nginx.lock \ --with-http_stub_status_module --with-http_ssl_module \ --with-http_gzip_static_module --with-http_sub_module \ --with-http_v2_module --with-http_mp4_module --with-http_flv_module \ --http-client-body-temp-path=/var/tmp/nginx/client \ --http-proxy-temp-path=/var/tmp/nginx/proxy \ --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi \ --with-pcre --add-module=/opt/fastdfs/fastdfs-nginx-module-1.22/src make && make install
6、tracker配置
#vim /etc/fdfs/tracker.conf ## 需要修改的内容如下 # tracker服务器端口(默认22122,一般不修改) port=22122 # 存储日志和数据的根目录 base_path=/home/fastdfs/tracker store_group=group1 max_connections=4000 # HTTP port on this tracker server http.server_port=80
7、storage配置
#vim /etc/fdfs/storage.conf ## 需要修改的内容如下 # storage所属的组 group_name=group1 # storage服务端口(默认23000,一般不修改) port=23000 # 数据和日志文件存储根目录 base_path=/home/fastdfs/storage # 第一个存储目录 store_path0=/home/fastdfs/storage/file # # tracker服务器IP和端口,不能写127.0.0.1 tracker_server=192.168.10.1:22122 # http访问文件的端口(默认8888,看情况修改,和nginx中保持一致) http.server_port=80
8、配置nginx访问
## 单台文件服务器可不用安装 #vim /etc/fdfs/mod_fastdfs.conf ##需要修改的内容如下 # 连接超时时间 connect_timeout=10 # the group name of the local storage server group_name=group1 storage_server_port=23000 #tracker服务器IP和端口 tracker_server=192.168.10.1:22122 url_have_group_name=true store_path0=/home/fastdfs/storage/file #配置nginx.conf vim /etc/nginx/nginx.conf #添加如下配置 server { listen 80; ## 该端口为storage.conf中的http.server_port相同 server_name localhost; location ~/group1/M00 { ngx_fastdfs_module; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } # 添加如下行,将 /group1/M00 映射 location ^~ /group1/M00 { alias /home/fastdfs/storage/file/data/; }
9、client测试
mkdir -p /home/fastdfs/client vim /etc/fdfs/client.conf ## 需要修改的内容如下 base_path=/home/fastdfs/client # tracker服务器IP和端口 tracker_server=192.168.10.1:22122 # HTTP settings # http.tracker_server_port=80 # 保存后测试,返回ID表示成功 如:group1/M00/00/00/xx.tar.gz fdfs_upload_file /etc/fdfs/client.conf /opt/fastdfs/libfastcommon-1.0.39.tar.gz
10、测试下载
# 测试下载,用外部浏览器访问刚才已传过的nginx安装包,引用返回的ID http://192.168.10.1:8801/group1/M00/00/00/wKgAQ1pysxmAaqhAAA76tz-dVgg.tar.gz # 弹出下载单机部署全部跑通
11、启动服务
#启动tracker服务 /etc/init.d/fdfs_trackerd start #自启动tracker服务 chkconfig fdfs_trackerd on #启动storage服务 /etc/init.d/fdfs_storaged start #自启动storage服务 chkconfig fdfs_storaged on service nginx restart #检测集群 /usr/bin/fdfs_monitor /etc/fdfs/storage.conf
文章源自新逸网络-https://www.xinac.net/9226.html
新逸IT技术
扫一扫关注微信公众号
评论