Ubuntu 18.04 install fastdfs, Nginx and related configurations

Ubuntu 18.04 install fastdfs and nginx, nginx module in the correct way

1. Installation Preparation

1.1 update apt

sudo apt update
sudo apt-get update

Note: the following are all the packages used in the installation of fastdfs and Nginx
Link: https://pan.baidu.com/s/1GqBrujqX8E432h8evCjnnA
Extraction code: 8k4g

1.2 view and install dependent environment (very important)

#Directly input the dependent module at the terminal or where is < debname >
whereis gcc, whereis libevent-dev......
# Precompiled gcc g + + dependency
sudo apt-get install bulid-essential
sudo apt-get install libtool
sudo apt-get install gcc-c++/gcc,g++
sudo apt-get install libevent-dev
# Install pcre dependency Library
sudo apt-get install libpcre3 libpcre3-dev
sudo apt-get install openssl # ubantu system comes with it. It's better to check it

1.3 download the installation package

Note: the fastdfs Nginx module version must be suitable for Nginx. Here, autistic people have tried to install chicken soup on many forums, which is poisoned. If the version is wrong, it is easy to crash. The main error should be in the make compilation process of Nginx

2. Installation process

2.1 install fastdfs dependency package

  1. Unzip libfastcommon-master.zip
unzip libfastcommon-master
  1. Enter the extracted directory of libfastcommon master
cd libfastcommon-master
  1. Precompiled. / make.sh
  1. Sudo. / make.sh install install libfastcommon
sudo ./make.sh install	

2.2 install fastdfs

  1. Extract fastdfs and enter the directory

    sudo unzip fastdfs-5.11.zip
    cd fastdfs-5.11/
  2. Perform compilation and installation (you can install directly in the unzip directory and then delete the installation package)

    sudo ./make install

2.3 configure tracking server tracker

  1. Copy the tracker.conf.sample file of / etc/fdfs / to tracker.conf

     sudo cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf
  2. Create the directory fastdfs/tracker in the / home/python / directory

      sudo mkdir –p /home/python/fastdfs/tracker
  3. Edit the / etc/fdfs/tracker.conf configuration file

    sudo vim /etc/fdfs/tracker.conf

2.4 configure storage storage server (basically the same as above)

sudo cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf
sudo mkdir –p /home/python/fastdfs/storage
sudo vim /etc/fdfs/storage.conf

tracker_server=Own ubuntu Of ip address:22122

2.5 start test after configuration

  1. Start the tracker and storage services and view the process

    sudo /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start
    sudo /usr/bin/fdfs_storaged /etc/fdfs/storage.conf start

    Note: when ubantu18.04 starts the tracker and storage service, the process PID number may not be displayed immediately according to the system reason, so if you don't see the prompt after starting the service, use ps aux | grep fdfs to view

  2. Test installation status

    Copy the client.conf file to the directory / etc/fdfs /

    sudo cp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf

    Edit the / etc/fdfs/client.conf file

    sudo vim /etc/fdfs/client.conf
    tracker_server=Own ubantu/linux Of IP address:22122

    Upload file test

    guo@spoiled:~/fdfs$ fdfs_upload_file /etc/fdfs/client.conf ~/Desktop/cwc.jpg 

3. Install Nginx and add fastdfs Nginx module

3.1 decompress Nginx and fastdfs Nginx module

  1. Unzip nginx-1.15.9.tar.gz (must be version 1.15.9)

  2. Unzip fastdfs-nginx-module_v1.16.tar.gz (it must be this module, version 1.16)

  3. Enter Nginx-1.15.9/ directory

    cd nginx-1.15.9/

3.2 enter Nginx-1.15.9 for compilation and installation

  1. Compile Nginx and add module

    ~/nginx-1.15.9$ sudo ./configure --prefix=/usr/local/nginx/ --add-module=/home/python/fastdfs-nginx-module/src/
  2. Compile complete for installation (most errors here)

    /nginx-1.15.9$ sudo make
    /nginx-1.15.9$ sudo make install

Note 1: make is the most error prone process. The main reason is that the fastdfs Nginx module does not match Nginx, which leads to all kinds of strange errors. However, I am not a C language scholar, and the errors are endless. If you encounter the following problems during compilation, you must remember to replace the fastdfs Nginx module

Note: the author has experienced this process, and then replaced fastdfs-Nginx-module_v1.16, which can be compiled successfully

Note 2: if the following error occurs, you need to modify the / src/config configuration file (this error is also a common error, but it does not occur in fastdfs-Nginx-module_v1.16.1, which is a successful compilation)

sudo vim fastdfs-nginx-module-master/src/config
# Modify the following two items
ngx_module_incs="/usr/include/fastdfs /usr/include/fastcommon/"
CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"

Restart compilation after modification

~/nginx-1.15.9$ sudo ./configure --prefix=/usr/local/nginx/ --add-module=/home/python/fastdfs-nginx-module/src/
~/nginx-1.15.9$ sudo make
~/nginx-1.15.9$ sudo make install

3.3 configuration

  1. Copy / mod_fastdfs.conf

    sudo cp fastdfs-nginx-module-master/src/mod_fastdfs.conf /etc/fdfs/mod_fastdfs.conf
  2. Modify mod_fastdfs.conf

    sudo vim /etc/fdfs/mod_fastdfs.conf
    # Modify content
    tracker_server=Own ubantu/linux Of IP address:22122
  3. Copy http.conf, mime.types

    sudo cp fastdfs-5.11/conf/http.conf /etc/fdfs/http.conf
    sudo cp fastdfs-5.11/conf/mime.types /etc/fdfs/mime.types
  4. Modify Nginx configuration

    sudo vim /usr/local/nginx/conf/nginx.conf
    //Add the following to the http entry:
        server {
        	listen	8888;
    	    server_name	localhost;
    	    location ~/group[0-9]/ {
    	    error_page   500 502 503 504  /50x.html;
    	    location = /50x.html {
                root   html;
  5. Start Nginx

    sudo /usr/local/nginx/sbin/nginx

    FASTDFS and Nginx installation and configuration are now completed. Please follow the steps strictly to complete successfully! Thank you!

Published 1 original article, won praise 1, visited 13
Private letter follow

Tags: Nginx sudo Python vim

Posted on Thu, 12 Mar 2020 01:53:31 -0700 by Zeekar