FastDFS integrated nginx (c)

 

Install a

Baidu Cloud : Address all attachments

unzip fastdfs-nginx-module-master.zip

[root@node02 mnt]# cd fastdfs-nginx-module-master/
[root@node02 fastdfs-nginx-module-master]# ll
The total amount of 8
-rw-r--r-- 1 root root 2804 5月  30 2017 HISTORY
-rw-r--r-- 1 root root 1722 5月  30 2017 INSTALL
drwxr-xr-x 2 root root  109 5月  30 2017 src
[root@node02 fastdfs-nginx-module-master]#

Install nginx

(1) The first step in installing pcre dependent on networked file compression download pcre rely wget http://downloads.sourceforge.net/project/pcre/pcre/8.37/pcre-8.37.tar.gz

drwxr-xr-x  9 es   es         186 10月  4 21:41 nginx-1.12.2
-rw-r--r--  1 root root    981687 10月  4 20:30 nginx-1.12.2.tar.gz
drwxr-xr-x  9 1169 1169     12288 10月  4 21:40 pcre-8.37
-rw-r--r--  1 root root   2041593 10月  4 20:30 pcre-8.37.tar.gz
The second step extracting archive file
tar -zvxf fpcre-8.37.tar.gz

After the third step ./configure complete, return to perform at pcre make directory, and finally run make install

(2) installed openssl, zlib, gcc dependent

yum -y install make zlib zlib-devel gcc-c++ libtool  openssl openssl-devel

(3) where the installation nginx --prefix specified path, - the source code path add-module designated module fastDFS of nginx

./configure --prefix=/usr/local/nginx_fdfs --add-module=/mnt/fastdfs-nginx-module-master/src

(4) using the command to extract the installation nginx

  • make && make install

Note: Nginx installation of expansion modules FastDFS Notes (this can also be installed)

We know, Nginx install Linux installation requires several related libraries, or a compile error occurs, these libraries are: 
1, gcc compiler is installed?
  Check whether the installation: yum List Installed | grep gcc
  perform the installation: yum install gcc -y
2, OpenSSL libraries have been installed?
  Check whether the installation: yum List Installed | grep OpenSSL
  to perform the installation: yum install OpenSSL OpenSSL-devel -y
3, PCRE library is installed?
  Check whether the installation: yum List Installed | grep PCRE
  perform the installation: PCRE PCRE-devel yum install -y
4, if the zlib library is installed?
  Check whether the installation: yum List Installed | grep zlib
  to perform the installation: zlib zlib-devel yum install -y
yum install gcc OpenSSL OpenSSL-devel PCRE PCRE-devel zlib zlib-devel -y

The second profile

1, the copy / mnt / fastdfs-nginx-module-master / mod_fastdfs.conf src directory files to / etc / under fdfs / directory, so as to start the normal Nginx;

2, modify mod_fastdfs.conf configuration file:

base_path=/opt/fastdfs/nginx_mod
tracker_server=192.168.180.104:22122
store_path0=/opt/fastdfs/storage/files
url_have_group_name = true

3, configure Nginx configuration file

# Interception request comprising the path / group [1-9] / M0 [ 0-9] requests, using the Nginx fastdfs forwarding modules: 
LOCATION ~ / Group [1-9] / M0 [0-9 ] {
     ngx_fastdfs_module;
}

Note: If the access occurs less than 404, check url_have_group_name = false

[root@node02 fdfs]# cat mod_fastdfs.conf
# connect timeout in seconds
# default value is 30s
connect_timeout=2
# network recv and send timeout in seconds
# default value is 30s
network_timeout=30
# the base path to store log files
base_path=/opt/fastdfs/nginx_mod
# if load FastDFS parameters from tracker server
# since V1.12
# default value is false
load_fdfs_parameters_from_tracker=true
# storage sync file max delay seconds
# same as tracker.conf
# valid only when load_fdfs_parameters_from_tracker is false
# since V1.12
# default value is 86400 seconds (one day)
storage_sync_file_max_delay = 86400
# if use storage ID instead of IP address
# same as tracker.conf
# valid only when load_fdfs_parameters_from_tracker is false
# default value is false
# since V1.13
use_storage_id = false
# specify storage ids filename, can use relative or absolute path
# same as tracker.conf
# valid only when load_fdfs_parameters_from_tracker is false
# since V1.13
storage_ids_filename = storage_ids.conf
# FastDFS tracker_server can ocur more than once, and tracker_server format is
#  "host:port", host can be hostname or ip address
# valid only when load_fdfs_parameters_from_tracker is true
tracker_server=192.168.180.104:22122
# the port of the local storage server
# the default value is 23000
storage_server_port=23000
# the group name of the local storage server
group_name=group1
# if the url / uri including the group name
# set to false when uri like /M00/00/00/xxx
# set to true when uri like ${group_name}/M00/00/00/xxx, such as group1/M00/xxx
# default value is false
url_have_group_name = true
# path(disk or mount point) count, default value is 1
# must same as storage.conf
store_path_count=1
# store_path#, based 0, if store_path0 not exists, it's value is base_path
# the paths must be exist
# must same as storage.conf
store_path0=/opt/fastdfs/storage/files
#store_path1=/home/yuqing/fastdfs1
# standard log level as syslog, case insensitive, value list:
### emerg for emergency
### alert
### crit for critical
### error
### warn for warning
### notice
### info
### debug
log_level=info
# set the log filename, such as /usr/local/apache2/logs/mod_fastdfs.log
# empty for output to stderr (apache and nginx error_log file)
log_filename=
# response mode when the file not exist in the local file system
## proxy: get the content from other storage server, then send to client
## redirect: redirect to the original storage server (HTTP Header is Location)
response_mode=proxy
# the NIC alias prefix, such as eth in Linux, you can see it by ifconfig -a
# multi aliases split by comma. empty value means auto set by OS type
# this paramter used to get all ip address of the local host
# default values is empty
if_alias_prefix=
# use "#include" directive to include HTTP config file
# NOTE: #include is an include directive, do NOT remove the # before include
#include http.conf

# if support flv
# default value is false
# since v1.15
flv_support = true
# flv file extension name
# default value is flv
# since v1.15
flv_extension = flv
# set the group count
# set to none zero to support multi-group on this storage server
# set to 0  for single group only
# groups settings section as [group1], [group2], ..., [groupN]
# default value is 0
# since v1.14
group_count = 0
# group settings for group #1
# since v1.14
# when support multi-group on this storage server, uncomment following section
#[group1]
#group_name=group1
#storage_server_port=23000
#store_path_count=2
#store_path0=/home/yuqing/fastdfs
#store_path1=/home/yuqing/fastdfs1
# group settings for group #2
# since v1.14
# when support multi-group, uncomment following section as neccessary
#[group2]
#group_name=group2
#storage_server_port=23000
#store_path_count=1
#store_path0=/home/yuqing/fastdfs

[root @ node02 FDF] #

Start with the three test
1 , starting with Nginx module fastdfs

2, restart fastDFS service process, execute the following command: fdfs_trackerd /etc/fdfs/tracker.conf restart fdfs_storaged / etc / FDFS / storage.conf restart

3 , upload a file to test verification:

fdfs_test /etc/fdfs/client.conf upload / root / aa.txt

4 , access to the uploaded file in a browser

[root@node02 conf]# /usr/local/nginx_fdfs/sbin/nginx -c  /usr/local/nginx_fdfs/conf/nginx.conf -t
ngx_http_fastdfs_set pid=5196
nginx: the configuration file /usr/local/nginx_fdfs/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx_fdfs/conf/nginx.conf test is successful
[root@node02 conf]#
[root@node02 conf]# /usr/local/nginx_fdfs/sbin/nginx -c  /usr/local/nginx_fdfs/conf/nginx.conf
ngx_http_fastdfs_set pid=5205
[root@node02 conf]#
[root@node02 ~]# cp anaconda-ks.cfg aa.txt
[root@node02 ~]# fdfs_test /etc/fdfs/client.conf upload /root/aa.txt
This is FastDFS client test program v5.11
Copyright (C) 2008, Happy Fish / YuQing
FastDFS may be copied only under the terms of the GNU General
Public License V3, which may be found in the FastDFS source kit.
Please visit the FastDFS Home Page http://www.csource.org/
for more detail.
[2019-11-09 13:47:00] DEBUG - base_path=/opt/fastdfs/client, connect_timeout=30, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s, use_storage_id=0, storage server id count: 0
tracker_query_storage_store_list_without_group:
        server 1. group_name=, ip_addr=192.168.180.104, port=23000
group_name=group1, ip_addr=192.168.180.104, port=23000
storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/wKi0aF3GUtSAb_FLAAAGwzv_BVg111.txt
source ip address: 192.168.180.104
file timestamp=2019-11-09 13:47:00
file size=1731
file crc32=1006568792
example file url: http://192.168.180.104/group1/M00/00/00/wKi0aF3GUtSAb_FLAAAGwzv_BVg111.txt
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/wKi0aF3GUtSAb_FLAAAGwzv_BVg111_big.txt
source ip address: 192.168.180.104
file timestamp=2019-11-09 13:47:00
file size=1731
file crc32=1006568792
example file url: http://192.168.180.104/group1/M00/00/00/wKi0aF3GUtSAb_FLAAAGwzv_BVg111_big.txt
[root@node02 ~]#

 

 

Guess you like

Origin www.cnblogs.com/dalianpai/p/11832217.html