As teacher Yu in V4.05 after the version of the built-in HTTP service removed, so even if you test the upload success, you can not access. We recommend that you use the Fastdfs-nginx-module module with Nginx,
After building the FASTDFS system, we can build the Web Access function.
The general idea has the following two kinds
1. Directly install the Nginx extension module on the Fastdfs collection Fastdfs-nginx-module
or directly install the Apache extension module on the Fastdfs collection Fastdfs-apache-module 2. After installing the Web software, the function of Fastdfs-nginx-module is realized by configuring Nginx.
The first kind (recommended).
Download Nginx and plug-in Fastdfs-nginx-module-master.zip the two software (if Nginx has been installed, need to recompile again, compile the plugin loaded)
(if Nginx is installed with Yum, you need to download the same version of Yum install package, recompile)
Here from the beginning install: Unzip: # TAR-ZXVF Nginx-1.13.5.tar.gz
# Unzip Fastdfs-nginx-module-master.zip
Installing Nginx and Fastdfs plugins:
./configure--prefix=/usr/local/nginx--ADD-MODULE=/HOME/PACKAGES/FASTDFS-NGINX-MODULE-MASTER/SRC
Consecutive error: Error: The HTTP rewrite module requires the PCRE library ....
Workaround: Yum Install pcre-devel.x86_64 error: The HTTP gzip module requires the Zlib library ....
Solution: Yum Install zlib-devel.x86_64
Compilation succeeded:
Adding module IN/HOME/PACKAGES/FASTDFS-NGINX-MODULE-MASTER/SRC+ Ngx_http_fastdfs_module was configured
Configuration Summary + using System PCRE Library + OpenSSL Library is not used + using System zlib Library
Nginx path prefix: "/usr/local/nginx" nginx binary file: "/usr/local/nginx/sbin/nginx" Nginx modules path: "/usr/local /nginx/modules "Nginx configuration prefix:"/usr/local/nginx/conf "Nginx configuration file:"/usr/local/nginx/conf/n ginx.conf "nginx pid file:"/usr/local/nginx/logs/nginx.pid "nginx error log file:"/usr/local/nginx/logs/error.log " Nginx HTTP access log file: "/usr/local/nginx/logs/access.log" nginx HTTP client request body Temporary files: "Client_ Body_temp "Nginx http proxy temporary files:" proxy_temp "Nginx http fastcgi temporary files:" Fastcgi_temp "Nginx H TTP Uwsgi Temporary files: "uwsgi_temp" Nginx http scgi temporary files: "Scgi_temp"
Continue installation: # make # make Install
Go to the Nginx installation directory and modify its configuration file: # cd/usr/local/nginx/conf # VI nginx.conf Add the following:
location/m00 {root/home/yuqing/fastdfs/data; Ngx_fastdfs_module; }
Create a new Soft connection: # Ln-s/home/yuqing/fastdfs/data/home/yuqing/fastdfs/data/m00
Copy and modify the mod_fastdfs.conf file: # CP mod_fastdfs.conf/etc/fdfs/# vi/etc/fdfs/mod_fastdfs.conf modified here: tracker_server= 10.0.0.42:22122
(Copy these two files to the Fdfs configuration file, or you can not access Nginx) (# cp/home/fastdfs-5.11/conf/http.conf/etc/fdfs/)
(# cp/home/fastdfs-5.11/conf/mime.types/etc/fdfs/)
Restart Nginx:
#/usr/local/nginx/sbin/nginx-s stop;
#/usr/local/nginx/sbin/nginx
Error: Browser cannot access
View Nginx error log as follows ERROR-FILE:INI_FILE_READER.C, line:631, include file "http.conf" not exists, line: "#include http.conf "Error-file:/home/packages/fastdfs-nginx-module-master/src/common.c, line:163, load conf file"/ETC/FDFS/MOD_FASTDF S.conf "fail, ret Code:2 solution: # cp/home/fastdfs-5.11/conf/http.conf/etc/fdfs/
ERROR-FILE:SHARED_FUNC.C, line:968, file/etc/fdfs/mime.types not exist fix: # Cp/home/fastdfs-5.11/conf/mime.types/et c/fdfs/
Access to Nginx success
Here's a look at the mod_fastdfs.conf file:# Connect timeout in seconds # default value is 30s connect_timeout=2 connection time-out
# Network recv and send timeout in seconds # default value is 30s network_timeout=30 send accept data time-out
# The base path to store log files base_path=/tmp log file location
# If load Fastdfs parameters from Tracker Server # since V1.12 # default value is False load_fdfs_parameters_from_tracker= True whether to read information from the Tracket server
If the information is not read from the Tracket server, the following three parameters are in effect # storage sync file max delay seconds # same as tracker.conf # valid only when Load_fdfs_param Eters_from_tracker is False # since V1.12 # default value was 86400 seconds (one day) Storage_sync_file_max_delay = 86400 When Load_fdfs_parameters_from_tracker is set to False, this parameter takes effect the maximum delay time of the synchronization file, same as the parameters in the tracker.conf file
The default is one day
# if use storage ID instead of IP address # Same as tracker.conf # valid if Load_fdfs_parameters_from_tracker was FA LSE # Default value is False # since V1.13 use_storage_id = False if storage_id is used
# Specify storage IDs filename, can use relative or absolute path # same as tracker.conf # valid if Load_fdfs_param Eters_from_tracker is false # since V1.13 Storage_ids_filename = storage_ids.conf
Location of the storage_id
# Fastdfs Tracker_server can ocur more than once, and Tracker_server format was # "Host:port", host can be hostname or IP Address # Valid If Load_fdfs_parameters_from_tracker is true tracker_server=10.0.0.42:22122 reads information from the Tracket server, This parameter takes effect Tracket server address, port
# The port of the local storage server # The default value is 23000 storage_server_port=23000 This storage server listening port
# The group name of the local storage server Group_name=group1 Group
# if the Url/uri including the group name # set to False when URIs Like/m00/00/00/xxx # set to True when URIs like ${grou P_name}/m00/00/00/xxx, such as Group1/m00/xxx # default value is False Url_have_group_name = False
whether a group name is included in the URL linksimilar to/m00/00/00/xxx and Group1/m00/00/00/xxxIf you select True to include the group name, you need to modify the Nginx configuration file Change location/m00 to Location/group1/m00 # path (disk or mount point) count, default value is 1 # must same as storage.conf store_path_count=1 storage path number, must and Stor age.conf file Consistency
# store_path#, based 0, if Store_path0 not exists, it's value is Base_path # The paths must be exist # must same as Storag e.conf Store_path0=/home/yuqing/fastdfs #store_path1 =/HOME/YUQING/FASTDFS1 Storage path address, must be consistent with storage.conf file
# Standard log level as syslog, case insensitive, Value list: # # # Emerg for emergency # # # alert # # Crit Error # # # # Warn for warning # # # notice # # # info # # Debug Log_level=info Log level
# Set the log filename, such as/usr/local/apache2/logs/mod_fastdfs.log # empty for output to stderr (Apache and Nginx err Or_log file) log_filename= set the name of the log to be logged in the error log of the HTTP service as empty
# response Mode when the file isn't exist in the local file system # # Proxy:get the content from other storage servers, then Send to Client # # Redirect:redirect to the original storage server (HTTP Header was location) response_mode=proxy
How to respond when a file does not exist locally proxy Agent, obtain content from other storage servers, and then send it to the customerredirect redirect HTTP headers for the original storage server
# 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 are EMP Ty if_alias_prefix= .... Multiple aliases are separated by commas, and Null indicates that the system type is set automatically this parameter is used to get all the IP of this machine
# "#include" directive to include HTTP config file # Note: #include are an include directive, does not remove the # befor E include #include http.conf use the # include directive to include HTTP profiles Note: #include this is a include directive, do not delete the # in front of include
# if support FLV # default value is False # since v1.15 Flv_support = True if FLV file is supported, default does not support
# flv file extension Name # default value is FLV # since v1.15 flv_extension = flv flv file extension, default is FLV
# set the group Count # set to none of zero-to-support Multi-group in 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
set the number of groups Set no 0, support multiple group groups on this storage serverset 0 to only one groupIf there are multiple groups on the server, the settings for the group are like this [group1], [group2], ..., [GROUPN]The default is 0, a set of
# Group settings for group #1 # since v1.14 # if 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 Set 1 if the storage server supports multiple groups, uncomment the following
# 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 Group 2 settings If the storage server supports multiple groups, uncomment the following
Second, the direct use of Web Access this is relatively simple, just need to assign the Web root directory to the Fastdfs storage directory is available
Third, several ideas of Web Access Fastdfs
3.1 Use group name only
Suitable for large pictures, group groups, each group has a backup
access address is similar to picture.xxx.com/groupx/m00/......jpgonly need a domain name; When you upload a picture, the value returned directly + the domain name is saved as a picture name: Picture.xxx.com/groupx/m00/......jpgThe front end uses one nginx to do the reverse proxy + load balancer configuration as follows:Upstream group1{server group1_storage1:80;
Server group1_storage2:80;
} upstream group2{server group2_storage1:80;
Server group2_storage2:80;
}
location/group1/m00{proxy_pass http://group1;} location/group2/m00{proxy_pass http://group2;}
Note: The machines in group1 and group2 are properly configured nginx.conf storage.conf and mod_fastdfs.conf files in nginx.conf
location/group1/m00 {root/home/yuqing/fastdfs/data;
Ngx_fastdfs_module;}
Pay particular attention to the two group names in the mod_fastdfs.conf file, whether the URLs contain group names
Group_name=
Url_have_group_name =
3.2 Using domain names only (deployed production environments)
Applies to fewer pictures, each group is a single run, no backup situation
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.