Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install fastdfs-nginx-module and nginx in FastDFS

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces FastDFS how to install fastdfs-nginx-module and nginx, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

FastDFS stores files on the Storage server through the Tracker server, but file replication is required between the storage servers in the same group, so there is a problem of synchronization delay. Suppose the Tracker server uploads the file to 192.168.4.125, and the file ID has been returned to the client after the upload is successful. At this point, the FastDFS storage cluster mechanism will synchronize this file to the same group storage 192.168.4.126. If the file has not been copied yet, if the client uses this file ID to fetch the file on 192.168.4.126, an error will occur that the file cannot be accessed. On the other hand, fastdfs-nginx-module can redirect the file to connect to the source server to retrieve the file, so as to avoid the file inaccessible error caused by the replication delay on the client.

1. Download fastdfs-nginx-module and extract it

# cd / usr/local

# wget https://sourceforge.net/projects/fastdfs/files/FastDFS%20Nginx%20Module%20Source%20Code/fastdfs-nginx-module_v1.16.tar.gz

# tar-zxvf fastdfs-nginx-module_v1.16.tar.gz

2. Edit the config file

# cd fastdfs-nginx-module/src/

# vi config

Edit the config file, execute the following command to batch replace and save exit

:% s+/usr/local/+/usr/+g

(press enter to replace)

3. Copy the configuration file in the fastdfs-nginx-module module to the / etc/fdfs directory and edit it

# cp / usr/local/fastdfs-nginx-module/src/mod_fastdfs.conf / etc/fdfs/

# vi / etc/fdfs/mod_fastdfs.conf

The modifications are as follows:

Connect_timeout=10 (default 2)

Base_path=/tmp (default is / tmp)

Tracker_server=192.168.121.110:22122 (default is tracker:22122)

Storage_server_port=23000 (default configuration is 23000)

Group_name=group1 (default configuration is group1)

Url_have_group_name = true (default is false)

Store_path0=/data/fastdfs (default is / home/yuqing/fastdfs)

4. Install the nginx dependent library

# yum install-y pcre-devel zlib-devel

5. Install nginx

# mv / root/ Desktop / nginx-1.8.1.tar.gz / usr/local/

# cd / usr/local

# tar-zxvf nginx-1.8.1.tar.gz

# cd nginx-1.8.1

#. / configure-prefix=/application/nginx/-add-module=../fastdfs-nginx-module/src/

# make & & make install

6. Copy some configuration files in FastDFS to the / etc/fdfs directory

# cp / usr/local/FastDFS/conf/http.conf / etc/fdfs/

# cp / usr/local/FastDFS/conf/mime.types / etc/fdfs/

7. Configure nginx

# vi / application/nginx/conf/nginx.conf

User root

Worker_processes 1

Events {

Worker_connections 1024

}

Http {

Include mime.types

Default_type application/octet-stream

Sendfile on

Keepalive_timeout 65

Server {

Listen 8888

Server_name localhost

Location ~ / group [0-9] / {

Ngx_fastdfs_module

}

Error_page 500 502 503 504 / 50x.html

Location = / 50x.html {

Root html

}

}

}

Description:

(1) "user root" is to solve the problem of downloading and operating Times 404.

(2) Port 8888 corresponds to http.server_port=8888 in / etc/fdfs/storage.conf

(3) if there should be more than one group for a storage, the access path is accompanied by a group name, for example: / group1/M00/00/00/**, corresponds to nginx configuration:

Location ~ / group [0-9] / {

Ngx_fastdfs_module

}

8. Copy the nginx service to the / etc/init.d/ directory and start

# cp / application/nginx/sbin/nginx / etc/init.d/

# / etc/init.d/nginx

# ss-lntup | grep 8888

Tcp LISTEN 0128 *: 8888 *: * users: (("nginx", 7308), ("nginx", 7309))

9. Access previously uploaded files through a browser

Enter in the browser

Http://192.168.121.110:8888/group1/M00/00/00/wKh6blkcHpiAAEBkAAC7L7_PW5E715.jpg

Thank you for reading this article carefully. I hope the article "how to install fastdfs-nginx-module and nginx in FastDFS" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report