First, the System installation directory
Source code package Directory/data/wwwrootlibevent installation directory/usr/local/libeventfastdfs installation directory/data/fastdfsnginx installation directory/data/nmp/nginx
Second, download FASTDFS installation package
https://sourceforge.net/projects/fastdfs/files/
such as: fastdfs_v5.08.tar.gz
https://sourceforge.net/projects/fastdfs/files/FastDFS%20Nginx%20Module%20Source%20Code/
Download Fastdfs's Nginx module source code such as: fastdfs-nginx-module_v1.16.tar.gz
Https://github.com/happyfish100/libfastcommon/archive/master.zip
Download Libfastcommon installation package such as: Libfastcommon-master.zip three, install Libfastcommon
> Uzip libfastcommon-master.zip> cd libfastcommon-master> ./make.sh>./make.sh Install
(* If you are prompted-bash:uzip:command not found you need to install zip)
Iv. Installation of Tracker
> Tar zxf fastdfs_v5.08.tar.gz> cd Fastdfs
Run./make.sh, if there is an error, a dependent package may be missing
> ./make.sh>./make.sh Install
After the installation succeeds, the executable file is in the following directory:
> ll/usr/bin/fdfs*
Configuration files in:
> Ll/etc/fdfs
V. Configuration of Tracker related informationwe createTracker Directory
> mkdir-m 777/data/tracker> cd/etc/fdfs> cp tracker.conf.sample tracker.conf> VI tracker.conf
Copies a copy of the tracker.conf configuration file and configures it.
#启用配置文件disabled =false# Set the port number of the tracker port=22122# set the tracker data file and log directory (pre-creation required) base_path=/data/tracker# Set the HTTP port number http.server_port=8080
V. Operation of Tracker
>/usr/bin/fdfs_trackerd/etc/fdfs/tracker.conf Restart
To see if the tracker boot was successful
> NETSTAT-UNLTP | grep Fdfs
(* Note the need to open the corresponding port in the firewall) can also be set to boot from
> vi/etc/rc.d/rc.local
Add the following content:
/usr/bin/fdfs_trackerd/etc/fdfs/tracker.conf restart
V. Configuration Storage Create storage directory
> mkdir-m 777/data/storage> cd/etc/fdfs> cp storage.conf.sample storage.conf> VI storage.conf
#启用配置文件disabled =false# group name, modify the port number of the group_name=group1# setting storage according to the actual situation port=23000# set storage log directory (pre-created) base_path=/ data/storage# storage path number, need to match Store_path number store_path_count=1# storage path store_path0=/data/storage# Tracker the IP address and port number of the server tracker_server=192.168.9.10:22122# set the HTTP port number http.server_port=8080
RunStorage
>/usr/bin/fdfs_storaged/etc/fdfs/storage.conf Restart
See if it's successful
> NETSTAT-UNLTP | grep Fdfs
See if the storage server is enlisted to the tracker server by Fdfs_monitor
>/usr/bin/fdfs_monitor/etc/fdfs/storage.conf
Six, the installation of Nginx Fastdfs module because previously installed Nginx, so we recompile the installation, view Nginx installation commands
>/data/nmp/nginx/sbin/nginx-v
Configure arguments:--prefix=/data/nmp/nginx--with-pcre=/usr/src/pcre-8.38
Unzip the Fastdfs-nginx-module and copy it to the/DATA/NMP.
> TAR-ZXF fastdfs-nginx-module_v1.16.tar.gz> cp-r fastdfs-nginx-module/data/nmp/
Then we find the original Nginx source package, if not found, re-next.
> TAR-ZXF nginx-1.8.1.tar.gz> cd nginx-1.8.1>./configure--prefix=/data/nmp/nginx--with-pcre=/usr/src/ pcre-8.38--add-module=/data/nmp/fastdfs-nginx-module/src> Make
(* Note here do not make install, or overwrite installed) if the middle appears
MAKE[1]: * * [OBJS/ADDON/SRC/NGX_HTTP_FASTDFS_MODULE.O] Error 1
Please enter into the fastdfs/client directory first
> Make && make Install
If not, modify the config file as follows (remove local)
> vi/data/nmp/fastdfs-nginx-module/src/configcore_incs= "$CORE _incs/usr/include/fastdfs/usr/include/ fastcommon/"
And then recompile, you should be able to succeed.
> CP Objs/nginx/data/nmp/nginx/sbin/nginx
We copy the mod_fastdfs.conf file under the module SRC to/etc/fdfs
> cp/data/nmp/fastdfs-nginx-module/src/mod_fastdfs.conf/etc/fdfs/
Modify config file # Store log directory Base_path=/data/storage#tracker server IP and port (can write multiple) tracker_server=192.168.9.10:22122# Whether storage belongs to the server group name Group_name=group1#url contains the group name Url_have_group_name = true# Place the file directory (can write multiple) store_path0=/data/storage
After the modification is complete, the startup Nginx found an error as follows:
[2016-04-15 01:31:46] ERROR-FILE:INI_FILE_READER.C, line:394, include file "http.conf" not exists, line: "#include http.conf" [2016-04-15 01: 31:46] Error-file:/data/nmp/fastdfs-nginx-module/src/common.c, line:155, load conf file "/etc/fdfs/mod_fastdfs.conf" Fail, ret Code:2
Copy http.conf and Mime.types under the Conf folder under the FASTDFS installation package to/etc/fdfs
> cp/data/wwwroot/fastdfs/conf/http.conf/etc/fdfs/> cp/data/wwwroot/fastdfs/conf/mime.types/etc/fdfs/
We create a new Nginx virtual host to test, my nginx installed under the/data/nmp/nginx, the virtual host configuration file placed under/data/nmp/nginx/conf/vhost/site.conf ( Note that you need to include the include vhost/*.conf in the Nginx.conf http{};).
server { #监听的端口号 listen 8080; #虚拟主机名 server_name www.site.com; Location ~/group[0-9]/m00 { #路径 root /data/storage/data; Ngx_fastdfs_module;} }
Create a symbolic link to the M00 store directory
> Ln-s/data/storage/data/data/storage/data/m00
Let's test if we create a successful copy of Client.conf.sample under/etc/fdfs/one for clien.conf
> cp/etc/fdfs/client.conf.sample/etc/fdfs/client.conf
Modify the following:
base_path=/data/storagetracker_server=192.168.9.10:22122http.tracker_server_port=8080
Create test.html, use/usr/bin/fdfs_test to test uploads
> echo "Test ..." > test.html>/usr/bin/fdfs_test/etc/fdfs/client.conf upload test.html
After success, return the following information:
This was FASTDFS Client test program V5.08copyright (C), Happy Fish/yuqingfastdfs could copied only under the terms Of the GNU generalpublic License V3, which May is found in the FASTDFS source kit. Visit the Fastdfs Home Page http://www.csource.org/for more detail. [2016-04-15 05:56:03] Debug-base_path=/data/storage, 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:0tracker_query_storage_store_list_without_group:server 1. Group_name=, ip_addr=192.168.9.10, Port=23000group_name=group1, ip_addr=192.168.9.10, Port=23000storage_upload_by_ Filenamegroup_name=group1, Remote_filename=m00/00/00/wkgjclcqefsaaelfaaaacmheljo22.htmlsource IP address: 192.168.9.10file timestamp=2016-04-15 05:56:04file size=8file crc32=3252589722example file url:http:// 192.168.9.10:8080/group1/m00/00/00/wkgjclcqefsaaelfaaaacmheljo22. Htmlstorage_upload_slave_by_filenamegroup_name=group1, Remote_filename=m00/00/00/wkgjclcqefsaaelfaaaacmheljo22 _big.htmlsource IP address:192.168.9.10file timestamp=2016-04-15 05:56:04file size=8file crc32=3252589722example file Url:http://192.168.9.10:8080/group1/m00/00/00/wkgjclcqefsaaelfaaaacmheljo22_big.html
By visiting the following URL, the test ... is displayed, indicating that the upload was successful.
Http://192.168.9.10:8080/group1/M00/00/00/wKgJClcQEfSAAELFAAAACMHelJo22_big.html
Of course, we can also use the following address to access.
Http://www.site.com:8080/group1/M00/00/00/wKgJClcQEfSAAELFAAAACMHelJo22_big.html
Installation of Fastdfs v5.08 Distributed File system under Linux