1 介紹
FastDFS安裝好了之后是無(wú)法通過(guò)http訪問(wèn)的,這個(gè)時(shí)候需要借助nginx來(lái)實(shí)現(xiàn),需要安裝fastdfs的第三方模塊到nginx中。
nginx需要和storage安裝在同一個(gè)節(jié)點(diǎn)
CSDN下載地址: https://download.csdn.net/download/qq_15769939/15804196
2 文件上傳
上傳文件到服務(wù)器,目錄為 /opt/module/software/FastDFS
[root@localhost ~]# cd /opt/module/software/FastDFS
[root@localhost FastDFS]# ll
總用量 1984
drwxrwxr-x. 12 root root 4096 12月 5 2019 fastdfs-6.04
-rw-r--r--. 1 root root 800157 3月 11 10:36 fastdfs-6.04.tar.gz
-rw-r--r--. 1 root root 19952 3月 11 10:36 fastdfs-nginx-module-1.22.tar.gz
drwxrwxr-x. 5 root root 153 3月 11 10:41 libfastcommon-1.0.42
-rw-r--r--. 1 root root 164704 3月 11 10:36 libfastcommon-1.0.42.tar.gz
-rw-r--r--. 1 root root 1032630 3月 11 10:36 nginx-1.16.1.tar.gz
3 安裝nginx與fastdfs模塊
3.1 修改nginx路徑
[root@localhost FastDFS]# tar -zxvf fastdfs-nginx-module-1.22.tar.gz
[root@localhost FastDFS]# cp mod_fastdfs.conf /etc/fdfs
[root@localhost FastDFS]# vi /fastdfs-nginx-module/src/config
修改內(nèi)容
ngx_module_incs="/usr/include"
CORE_INCS="$CORE_INCS /usr/include"
3.2 安裝fastdfs模塊
安裝fastdfs模塊分為兩種情況,一種是服務(wù)器上尚未安裝nginx,這里正常按照步驟操作就可以。另外一種是已經(jīng)安裝過(guò)了nginx,這里只需要單獨(dú)掛載模塊就可以。
3.2.1 未安裝nginx
對(duì)未安裝過(guò)nginx的服務(wù)器安裝,只需要在安裝nginx的時(shí)候,加入第三方模塊就行.
具體的安裝步驟可以參考博文:Centos7 安裝nginx和運(yùn)行
將博文中的4.3.2的自定義配置換成下面的配置即可:
./configure \
--prefix=/usr/local/nginx \
--conf-path=/usr/local/nginx/conf/nginx.conf \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/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=/opt/module/software/FastDFS/fastdfs-nginx-module-1.22/src
3.2.3 已安裝nginx
這里只
make編譯,不進(jìn)行make install安裝
[root@localhost FastDFS]# cd /opt/module/software/nginx-1.16.1
[root@localhost nginx-1.16.1]# make
[root@localhost nginx-1.16.1]# cp /opt/module/software/nginx-1.16.1/objs/nginx /usr/local/nginx/sbin
3.3 修改nginx配置
[root@localhost nginx-1.16.1]# vi /opt/module/software/nginx-1.16.1/conf/nginx.conf
server {
listen 8888
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location /auskat/M00 {
ngx_fastdfs_module;
}
}
4 修改FastDFS配置
[root@localhost FastDFS]# cp /opt/module/software/FastDFS/fastdfs-nginx-module-1.22/src/mod_fastdfs.conf /etc/fdfs/
[root@localhost fdfs]# mkdir /usr/local/fastdfs/tmp
[root@localhost fdfs]# vi /etc/fdfs/mod_fastdfs.conf
修改內(nèi)容
base_path=/usr/local/fastdfs/tmp
tracker_server=192.168.51.5:22122
group_name=auskat
url_have_group_name=true
store_path0=/usr/local/fastdfs/storage
5 功能測(cè)試
啟動(dòng)nginx服務(wù)
[root@localhost sbin]# /usr/local/nginx/sbin/nginx
ngx_http_fastdfs_set pid=36759
訪問(wèn)圖片
http://192.168.51.6:8888/auskat/M00/00/00/wKgzBmBJiUeAI4QjAAUXmkbISCM506.jpg

image-20210315151210613.png
6 相關(guān)信息
- 博文不易,辛苦各位猿友點(diǎn)個(gè)關(guān)注和贊,感謝