1 Introduction
After FastDFS is installed, it cannot be accessed through http. At this time, you need to use nginx to achieve it. You need to install the third-party module of fastdfs into nginx.
nginx needs to be installed on the same node as storage
CSDN download address: https://download.csdn.net/download/qq_15769939/15804196
2 File upload
Upload files to the server, the directory is /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 Install nginx and fastdfs modules
3.1 Modify nginx path
[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
修改内容
ngx_module_incs="/usr/include"
CORE_INCS="$CORE_INCS /usr/include"
3.2 Install fastdfs module
There are two situations for installing the fastdfs module. One is that nginx has not been installed on the server. Just follow the steps normally. The other is that nginx has already been installed, and you only need to mount the module separately.
3.2.1 nginx is not installed
For server installations that have not installed nginx, you only need to add third-party modules when installing nginx.
The specific installation steps can refer to the blog post: Centos7 install nginx and run
Replace the custom configuration of 4.3.2 in the blog post with the following configuration:
./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 Installed nginx
Here only
make
compile withoutmake install
installation
[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 modify nginx configuration
[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 Modify FastDFS configuration
[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
修改内容
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 Function test
启动nginx服务
[root@localhost sbin]# /usr/local/nginx/sbin/nginx
ngx_http_fastdfs_set pid=36759
访问图片
http://192.168.51.6:8888/auskat/M00/00/00/wKgzBmBJiUeAI4QjAAUXmkbISCM506.jpg
6 Related information
- The blog post is not easy, everyone who has worked so hard to pay attention and praise, thank you