1. Linux VMS are available
  • Centos7 process slightly
  1. Download the software
> mkdir -p /opt/tar
> cd /opt/tar

#Making address: https://github.com/happyfish100
>Wget https://github.com/happyfish100/fastdfs/archive/V5.11.tar.gz - O/opt/tar/fastdfs5.11 tar. Gz
>Wget https://github.com/happyfish100/libfastcommon/archive/V1.0.39.tar.gz - O/opt/tar/libfastcommon1.0.39 tar. Gz
>Wget https://github.com/happyfish100/fastdfs-nginx-module/archive/V1.20.tar.gz - O The/opt/tar/fastdfs - nginx - module1.20. Tar. Gz
>Wget http://nginx.org/download/nginx-1.20.2.tar.gz - O/opt/tar/nginx - 1.20.2. Tar. Gz

#Installing the Compilation tool
#FastDFS is developed in C language. To install FastDFS, you need to compile the source code downloaded from the official website first. The compilation depends on the GCC environment
> yum install -y gcc gcc-c++ 
#FastDFS relies on the Libevent library, perl library, which needs to be installed
> yum -y install libevent
> yum -y install perl
#Libfastcommon is official with FastDFS. Libfastcommon contains some of the basic libraries needed to run FastDFS

Copy the code
  1. Install FastDFS
#FastDFS dependent JAR package processing
#compile
> cd /opt/tar
>The tar - ZXVF libfastcommon. 1.0.39. Tar. Gz 
> cdLibfastcommon 1.0.39 /
#Compile and package libfastcommon
> ./make.sh
#The installation
#Install libfastcommon
> ./make.sh install
mkdir -p /usr/lib64
mkdir -p /usr/lib
mkdir -p /usr/include/fastcommon
install -m 755 libfastcommon.so /usr/lib64
install -m 644 common_define.h hash.h chain.h logger.h base64.h shared_func.h pthread_func.h ini_file_reader.h _os_define.h sockopt.h sched_thread.h http_func.h md5.h local_ip_func.h avl_tree.h ioevent.h ioevent_loop.h fast_task_queue.h fast_timer.h process_ctrl.h fast_mblock.h connection_pool.h fast_mpool.h fast_allocator.h fast_buffer.h skiplist.h multi_skiplist.h flat_skiplist.h skiplist_common.h system_info.h fast_blocked_queue.h php7_ext_wrapper.h id_generator.h char_converter.h char_convert_loader.h common_blocked_queue.h multi_socket_client.h skiplist_set.h fc_list.h /usr/include/fastcommon
if [ ! -e /usr/lib/libfastcommon.so ]; then ln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.so; fi
#After libfastcommon is installed, the libfastcommon.so library file is generated in /usr/lib64
> ll /usr/lib64 | grep "libfastcommon.so"
-rwxr-xr-x.  1 root root  957656 Nov 28 20:55 libfastcommon.so
#Because the FastDFS program references the /usr/lib directory, you need to copy libfastcommon.so from /usr/lib64 to /usr/lib
#Or create the form of a hyperlink: ln -s/usr/lib64 / libfastcommon. So/usr/lib/libfastcommon. So
> cp /usr/lib64/libfastcommon.so /usr/lib/

#Install FastDFS
> cd /opt/tar
>The tar - ZXVF FastDFS. 5.11. The tar. Gz
> cdFastdfs - 5.11 /
#compile
#Yum -y install perl yum -y install perl yum -y install perl /make
#Sh clean to clean up the previous compilation file and then recompile it./make
> ./make.sh

#The installation
#Install FastDFS
>  ./make.sh installmkdir -p /usr/bin mkdir -p /etc/fdfs cp -f fdfs_trackerd /usr/bin if [ ! -f /etc/fdfs/tracker.conf.sample ]; then cp -f .. /conf/tracker.conf /etc/fdfs/tracker.conf.sample; fi if [ ! -f /etc/fdfs/storage_ids.conf.sample ]; then cp -f .. /conf/storage_ids.conf /etc/fdfs/storage_ids.conf.sample; fi mkdir -p /usr/bin mkdir -p /etc/fdfs cp -f fdfs_storaged /usr/bin if [ ! -f /etc/fdfs/storage.conf.sample ]; then cp -f .. /conf/storage.conf /etc/fdfs/storage.conf.sample; fi mkdir -p /usr/bin mkdir -p /etc/fdfs mkdir -p /usr/lib64 mkdir -p /usr/lib cp -f fdfs_monitor fdfs_test fdfs_test1 fdfs_crc32 fdfs_upload_file fdfs_download_file fdfs_delete_file fdfs_file_info fdfs_appender_test fdfs_appender_test1 fdfs_append_file fdfs_upload_appender /usr/bin if [ 0 -eq 1 ]; then cp -f libfdfsclient.a /usr/lib64; cp -f libfdfsclient.a /usr/lib/; fi if [ 1 -eq 1 ]; then cp -f libfdfsclient.so /usr/lib64; cp -f libfdfsclient.so /usr/lib/; fi mkdir -p /usr/include/fastdfs cp -f .. /common/fdfs_define.h .. /common/fdfs_global.h .. /common/mime_file_parser.h .. /common/fdfs_http_shared.h .. /tracker/tracker_types.h .. /tracker/tracker_proto.h .. /tracker/fdfs_shared_func.h .. /storage/trunk_mgr/trunk_shared.h tracker_client.h storage_client.h storage_client1.h client_func.h client_global.h fdfs_client.h /usr/include/fastdfs if [ ! -f /etc/fdfs/client.conf.sample ]; then cp -f .. /conf/client.conf /etc/fdfs/client.conf.sample; fi> cd /usr/bin
#View the installed FastdFS related files
> ll fdfs* 

#The configuration file is initialized
#View the configuration file and back up the sample configuration file to the smaple.bak folder
> cd /etc/fdfs/
> mkdir sample.bak
> mv *.sample sample.bak
#Copy the fastdfs configuration file to the /etc/fdfs working directory
>Cp/opt/tar/fastdfs - 5.11 / conf / * / etc/FDFS /
#Create a directory to prepare log data after the server is started
> mkdir -p /opt/fastdfs/tracker
> mkdir -p /opt/fastdfs/storage
> mkdir -p /opt/fastdfs/client

#Configuring the Tracker Service
#Where port=22122 The springBoot configuration will apply the service port, that is, the service port of the Tracker server
#Change bash_path=/opt/fastdfs/tracker // Directory where log data is stored
> cd /etc/fdfs
> vi tracker.conf
#Start the tracker
>/usr/bin/./fdfs_trackerd /etc/fdfs/tracker.conf
#If the configuration is modified, run the /usr/bin/./fdfs_trackerd /etc/fdfs/tracker.conf restart command to restart the tracker server 

#Configuring storage Services
#Go to the configuration file directory and modify the storage.conf configuration 
#Base_path =/opt/fastdfs/storage, // Directory for storing log data
#Group_name =fxin(context root)
#Store_path0 =/opt/fastdfs/storage // Location for storing images
#Tracker_server =192.168.3.210:22122 // Tracker server address information
> cd /etc/fdfs/
> vi storage.conf
#Start the storage server
>  /usr/bin/./fdfs_storaged /etc/fdfs/storage.conf 
#If the configuration is modified, run the /usr/bin/./fdfs_storaged /etc/ffs/storage. conf restart command to restart the storage server

#Configuring the Client Service
#Go to the configuration file directory and configure the client
#Base_path =/opt/fastdfs/client // Directory for storing log data
#Tracker_server =192.168.3.210:22122 // Tracker server address information
> cd /etc/fdfs/
> vi client.conf
#Use FastDFS built-in tools to test
#Test uploading an image through client
#Upload FILE format the Usage: / usr/bin/fdfs_test < config_file > upload < local_filename > [FILE | BUFF | CALLBACK] 
> /usr/bin/./fdfs_test /etc/fdfs/client.conf upload /tmp/img/logo.pngThis 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. [2021-12-01 01:01:23] 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.3.210, port=23000 group_name=fxin, ip_addr=192.168.3.210, port=23000 storage_upload_by_filename group_name=fxin, remote_filename=M00/00/00/wKgD0mGnD7OAUmLSAAAWH0Uu4hU808.png source ip address: 192.168.3.210 File TIMESTAMP =2021-12-01 01:01:23 File size=5663 file crc32=1160700437 example file URL: http://192.168.3.210/fxin/M00/00/00/wKgD0mGnD7OAUmLSAAAWH0Uu4hU808.png storage_upload_slave_by_filename group_name = fxin,  remote_filename=M00/00/00/wKgD0mGnD7OAUmLSAAAWH0Uu4hU808_big.png source ip address: 192.168.3.210 File TIMESTAMP =2021-12-01 01:01:23 File size=5663 file crc32=1160700437 example file URL: http://192.168.3.210/fxin/M00/00/00/wKgD0mGnD7OAUmLSAAAWH0Uu4hU808_big.png
#At this point, the FastdFS server configuration is complete, but the file URL is now inaccessible and a Web server needs to be configured
Copy the code
  1. Install Nginx
> cd /opt/tar
>The tar - ZXVF fastdfs - nginx - module - 1.20. Tar. Gz
> cd/ opt/tar/fastdfs - nginx - module - 1.20 / SRC
#Modifying a Configuration File
#Put the following two lines:
# ngx_module_incs="/usr/local/include"
# CORE_INCS="$CORE_INCS /usr/local/include"
#Replaced by:
# ngx_module_incs="/usr/include/fastdfs /usr/include/fastcommon/"
# CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"
> vi config

#Install nginx
> cd /opt/tar
>The tar - ZXVF nginx - 1.20.2. Tar. Gz 
# yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
#Added gCC-C ++ support
> yum -y install gcc-c++
#Added regular expression support
> yum -y install pcre pcre-devel
> yum -y install zlib zlib-devel
> yum -y install openssl openssl-devel
#Set up the nginx configuration file
> cd/ opt/tar/nginx - 1.20.2
> ./configure \
--prefix=/usr/local/nginx \
--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/ngxin/client \ --http-proxy-temp-path=/var/temp/ngxin/proxy \ --http-fastcgi-temp-path=/var/temp/ngxin/fastcgi \ --http-uwsgi-temp-path=/var/temp/nginx/uwsgi \ --http-scgi-temp-path=/var/temp/nginx/scgi \ - add - the module = / opt/tar/fastdfs - nginx - module - 1.20 / SRCChecking for OS + Linux 3.10.0-1160.45.el7.x86_64 X86_64 Checking for C Compiler... Checking for Gcc-PIPE Switch Found + using GNU C Compiler + GCC version: 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) Checking for Gcc-PIPE Switch... found checking for -Wl,-E switch ... found ... . checking for getaddrinfo() ... Found Additional modules adding module in /opt/tar/ fastdfS-nginx-module-1.20 / SRC + ngx_http_fastDFs_module configuring Additional modules in /opt/tar/ Fastdfs-nginx-module-1.20 / SRC + ngx_http_fastDFs_module was configured checking for PCRE library ... found checking for PCRE JIT support ... found checking for zlib library ... found creating objs/Makefile 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/nginx.conf" nginx pid file: "/var/run/nginx/nginx.pid" nginx error log file: "/var/log/nginx/error.log" nginx http access log file: "/var/log/nginx/access.log" nginx http client request body temporary files: "/var/temp/ngxin/client" nginx http proxy temporary files: "/var/temp/ngxin/proxy" nginx http fastcgi temporary files: "/var/temp/ngxin/fastcgi" nginx http uwsgi temporary files: "/var/temp/nginx/uwsgi" nginx http scgi temporary files: "/var/temp/nginx/scgi"
#Compile nginx
> make. . cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -DFDFS_MOD_CONF_FILENAME='"/etc/fdfs/mod_fastdfs.conf"' -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \ -o objs/src/core/ngx_sha1.o \ ... . objs/ngx_modules.o \ -ldl -lpthread -lcrypt -lfastcommon -lfdfsclient -lpcre -lz \ -Wl,-E sed -e "s|%%PREFIX%%|/usr/local/nginx|" \ -e "s|%%PID_PATH%%|/var/run/nginx/nginx.pid|" \ -e "s|%%CONF_PATH%%|/usr/local/nginx/conf/nginx.conf|" \ -e "s|%%ERROR_LOG_PATH%%|/var/log/nginx/error.log|" \ < man/nginx.8 > objs/nginx.8#Install nginx
> make install"make -f objs/Makefile install make[1]: If the directory ` / opt/tar/nginx - 1.20.2 'test - d'/usr/local/nginx '| | mkdir -p'/usr/local/nginx 'test - d '/usr/local/nginx/sbin' \ || mkdir -p '/usr/local/nginx/sbin' test ! -f '/usr/local/nginx/sbin/nginx' \ || mv '/usr/local/nginx/sbin/nginx' \ '/usr/local/nginx/sbin/nginx.old' cp objs/nginx  '/usr/local/nginx/sbin/nginx' test -d '/usr/local/nginx/conf' \ || mkdir -p '/usr/local/nginx/conf' cp conf/koi-win '/usr/local/nginx/conf' cp conf/koi-utf '/usr/local/nginx/conf' cp conf/win-utf '/usr/local/nginx/conf' test -f '/usr/local/nginx/conf/mime.types' \ || cp conf/mime.types '/usr/local/nginx/conf' cp conf/mime.types '/usr/local/nginx/conf/mime.types.default' test -f '/usr/local/nginx/conf/fastcgi_params' \ || cp conf/fastcgi_params '/usr/local/nginx/conf' cp conf/fastcgi_params \ '/usr/local/nginx/conf/fastcgi_params.default' test -f '/usr/local/nginx/conf/fastcgi.conf' \ || cp conf/fastcgi.conf '/usr/local/nginx/conf' cp conf/fastcgi.conf '/usr/local/nginx/conf/fastcgi.conf.default' test -f '/usr/local/nginx/conf/uwsgi_params' \ || cp conf/uwsgi_params '/usr/local/nginx/conf' cp conf/uwsgi_params \ '/usr/local/nginx/conf/uwsgi_params.default' test -f '/usr/local/nginx/conf/scgi_params' \ || cp conf/scgi_params '/usr/local/nginx/conf' cp conf/scgi_params \ '/usr/local/nginx/conf/scgi_params.default' test -f '/usr/local/nginx/conf/nginx.conf' \ || cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf' cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf.default' test -d '/var/run/nginx' \ || mkdir -p '/var/run/nginx' test -d '/var/log/nginx' \ || mkdir -p '/var/log/nginx' test -d '/usr/local/nginx/html' \ || cp -R html '/usr/local/nginx' test -d '/var/log/nginx' \ || mkdir -p '/var/log/nginx' Make [1] : brigade directory ` / opt/tar/nginx - 1.20.2 '"
#Check the nginx installation at /usr/localThe nginx software directory appears below
> cd /usr/local
> ls | grep nginx

#Configure the bridge between nginx and fastdfs mod_fastdfs.conf
> cd/ opt/tar/fastdfs - nginx - module - 1.20 / SRC
> cp mod_fastdfs.conf /etc/fdfs/
> mkdir /opt/fastdfs/tmp
#Modify the configuration
# base_path=/opt/fastdfs/tmp
#Tracker_server = 192.168.3.210:22122
# group_name=fxin
# url_have_group_name = true// FXIN is enabled by default
> vi /etc/fdfs/mod_fastdfs

#Configure nginx
> cd /usr/local/nginx/conf
#Add a local service reverse proxyserver { listen 89; Server_name 192.168.3.210; Location /fxin/M00 {# add nginx and fastdfs module ngx_fastDFs_module; }}#
> vi ngxin_config
#Check that the nginx configuration is ok
> cd /usr/local/nginx/sbin
> ./nginx -t
#Check out all kinds of files without directory, all kinds of error slightly, fill directory
> mkdir -p /var/tmp/ngxin/client
> mkdir -p /var/temp/ngxin/client
>  mkdir -p /var/temp/nginx/uwsgi
#After replenishing the directory, run the test ngxin configuration successfully
> ./nginx -t
ngx_http_fastdfs_set pid=12622
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful 
#Start the ngxin
> ./nginx
Copy the code

Access to images

#Access the address: http://192.168.3.210:89/fxin/M00/00/00/wKgD0mGnD7OAUmLSAAAWH0Uu4hU808_big.png
#Nginx: nginx: nginx: nginx: nginx: nginx: nginx
> cd /etc/fdfs
#Modify the mod_fastdfs.conf configuration file
# store_path0=/opt/fastdfs/storage
> vi mod_fastdfs.conf  
#Restarting services
>  /usr/bin/./fdfs_trackerd /etc/fdfs/tracker.conf restart
>  /usr/bin/./fdfs_storaged /etc/fdfs/storage.conf restart
>  /usr/local/nginx/sbin/nginx -s reload
Copy the code

Centos7 FastDFS and Nginx are enabled upon startup

#Modifying a Configuration File
# # add command
# /usr/bin/./fdfs_trackerd /etc/fdfs/tracker.conf restart
# /usr/bin/./fdfs_storaged /etc/fdfs/storage.conf restart
# /usr/local/nginx/sbin/
> vi /etc/rc.d/rc.local
#In centos7, the permissions of /etc/rc.d/rc.local file have been reduced. You need to add executable permissions to the rc.local file
> chmod +x /etc/rc.d/rc.local
Copy the code