命令:yum install git gcc gcc-c++ make automake vim wget libevent -y
2.1:创建目录
mkdir /root/fastdfs
2.2:下载:进入fastdfs目录进行下载
命令:git clone https://github.com/happyfish100/libfastcommon.git --depth 1
2.3:编译安装:下载完成后进去libfastcommon执行编译安装
命令:./make.sh && ./make.sh install
3.1:返回/root/fastdfs目录下,进行下载。
命令:wget https://github.com/happyfish100/fastdfs/archive/V5.11.tar.gz
3.2:解压压缩包进入fastdfs-5.11目录,进行编译安装
所需命令:
tar -zxvf V5.11.tar.gz
cd fastdfs-5.11
./make.sh && ./make.sh install
3.3:#配置文件准备:复制所需配置文件到/etc/fdfs目录下
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 /root/fastdfs/fastdfs-5.11/conf/http.conf /etc/fdfs
cp /root/fastdfs/fastdfs-5.11/conf/mime.types /etc/fdfs
3.4:修改配置文件tracker.conf和
命令:vim /etc/fdfs/tracker.conf
需要修改的内容:port=22122和base_path=/home/fastdfs
命令:vim /etc/fdfs/storage.conf
需修改内容:
port=23000
base_path=/home/fastdfs # 数据和日志文件存储根目录
store_path0=/home/fastdfs # 第一个存储目录
tracker_server=192.168.211.136:22122
http.server_port=8888 # http访问文件的端口(默认8888,看情况修改,和nginx中保持一致)
启动前先创建出第一存储目录。修改配置文件后需自己创建存储目录:mkdir /home/fastdfs -p
启动命令:1:/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
2:/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
查询端口占用:netstat -ntlp
注意:netstat如果没有此命令,先执行:yum install net-tools -y
vim /etc/fdfs/client.conf
#需要修改的内容如下
base_path=/home/fastdfs
tracker服务器IP和端口:tracker_server=192.168.231.132:22122
保存后测试,执行命令:/usr/bin/fdfs_upload_file /etc/fdfs/client.conf /root/fastdfs/111.jpg
返回ID表示成功:group1/M00/00/00/wKjnhGB2pZqASEhHAAy_jNWQUuQ875.jpg
6.1:进入/root/fastdfs下载资源。
命令:wget https://github.com/happyfish100/fastdfs-nginx-module/archive/V1.20.tar.gz
6.2:解压:tar -xvf V1.20.tar.gz
6.3:修改fastdfs-nginx-module-1.20/src下的config:vim config
修改项:
ngx_module_incs="/usr/include/fastdfs /usr/include/fastcommon/"
CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"
6.4:将mod_fastdfs.conf复制到/etc/fdfs/目录下:cp mod_fastdfs.conf /etc/fdfs/
6.5:修改配置文件/etc/fdfs/mod_fastdfs.conf。
需要修改的内容如下:
tracker_server=192.168.211.136:22122
url_have_group_name=true
store_path0=/home/fastdfs
命令: vim /etc/fdfs/mod_fastdfs.conf
6.5:创建所需目录:mkdir -p /var/temp/nginx/client
7.1:进入fastdfs下载所需安装文件:
命令:1:cd /root/fastdfs
2:wget http://nginx.org/download/nginx-1.15.6.tar.gz
7.2:解压nginx文件:tar -xvf nginx-1.15.6.tar.gz
7.3:进入nginx-1.15.6的目录下,先安装所需插件,再添加fastdfs-nginx-module模块
命令:1:cd nginx-1.15.6
2:yum -y install pcre-devel openssl openssl-devel
3:./configure --add-module=/root/fastdfs/fastdfs-nginx-module-1.20/src
7.4:编译安装
命令:make && make install
7.5:查看模块是否安装:/usr/local/nginx/sbin/nginx -V
7.6:修改nginx配置文件
命令:vim /usr/local/nginx/conf/nginx.conf
添加配置:
server {
listen 8888;
server_name localhost;
location ~/group[0-9]/ {
ngx_fastdfs_module;
}
}
7.7:启动:/usr/local/nginx/sbin/nginx
关闭防火墙:systemctl stop firewalld:
使用浏览器访问上传的图片:
http://192.168.211.136:8888/group1/M00/00/00/wKjTiF7h5EWASb5aAACGZa9JdFo611.png