Configure fastdfs with nginx under Linux

Link to the original text of this article: https://blog.csdn.net/wgp15732622312/article/details/78822218

    Tool preparation: 

     CentOS 6.5

     fastdfs-master-V5.05.zip

     fastdfs-nginx-module-master.zip

     libfastcommon-master.zip

     nginx-1.13.7.zip


1. Install libfastcommon

    First upload all required compressed packages under the /usr/local/fastdfs path.

  Install the libfastcommon module. unzip libfastcommon

  Command: unzip libfastcommon-master.zip

 Then enter the unzipped directory

   Command: ./make.sh Compilation is complete

   Command: ./make.sh install install


2. Install fastdfs-master-v5.05.zip

  Command: unzip fastdfs-master-v5.05.zip decompress fastdfs compressed package

       Then enter the unzipped directory

Command: ./make.sh && ./make.sh install Compile and install


 3. Copy the configuration files in the fastdfs-master directory to the /etc/fdfs folder

     Command: cd fastdfs-master    

     cp -r conf/*   /etc/fdfs


4. Modify the configuration of tracker.conf, storage.conf and client.conf, pay attention to the configuration files in /etc/fdfs

       Modify tracker.conf first

       Command: vim tracker.conf Modify the port number, and the directory where data and log are stored. There must be a directory.


  The steps to modify storage.conf are the same as those for modifying tracker.conf. Mainly modify the directories storing data and logs, and point to the ip and port of the tracker server


5. Install the fastdfs-nginx-module module

     FastDFS stores files on the storage server through the tracker server, but files need to be copied between the same group of storage, and there is a problem of synchronization delay. That is to say, when the client uploads the file to a storage and then downloads the file from the storage cluster, the file has not been synchronized with the storage group at this time, which will cause the client to fail to obtain the file and an error will occur. The fastdfs-nginx-module The module will connect the file to the storage server uploaded by the user.

    unzip fastdfs-nginx-module

           Command: unzip fastdfs-nginx-module.zip

           Modify the configuration file: vim mod_fastdfs.conf



  After completing this step, copy mod_fastdfs.conf to the /etc/fdfs/ directory

       Command: cp mod_fastdfs.conf /etc/fdfs


That's it for the part about configuration files. Next, add the fastdfs-nginx-module module to nginx.

First, uninstall the nginx that you installed yourself. Just delete it directly.

6. Configure nginx modules

First find the compressed package of nginx, and then decompress it

     Command: tar nginx-1.13.7.tar.gz

Then enter the nginx decompressed directory, you will see a configure file, and then modify the configuration to add the fastdfs-nginx module.

# --prefix specifies which directory nginx is installed to, add the directory of fastdfs-nginx-module after add-module

      命令: ./configure --prefix=/usr/local/nginx2/ --add-module=../fastdfs-nginx-module/src/

      Command: ./make

      Command: ./make install

7. Modify the configuration file of nginx

 Enter the directory where nginx is installed, modify the configuration of nginx.conf, and add the access server mapping of fastdfs

    Command: vim nginx.conf




Eight, tracker service, storage service, use fastdfs client to upload pictures

        Command: /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf #Start tracker service

        Command: /usr/bin/fdfs_storaged /etc/fdfs/storage.conf #Start storage service

        Instruction: /usr/bin/fdfs_test /etc/fdfs/client.conf upload anti-steal.jpg



Result after upload


9. Turn off the firewall of the virtual machine and access the picture

Command: service firewalld stop

 View content on browser




Guess you like

Origin blog.csdn.net/qq_15098623/article/details/103334106