Preparation:

1. CentOS server 1, I installed a centOS 2 in the VIRTUAL machine. file

Pan.baidu.com/s/1aWTv02CQ…


yum -y install gcc gcc-c++

Start installation steps:

Transfer the required software to the server

Install FDFS

FastDfs relies on Libevent. You need to install libevent first

yum install -y libevent

Unzip libfastcommon – 1.0.7. Zip

Unzip libfastcommon – 1.0.7.zip CD libfastcommon – 1.0.7

Run the./make. Sh and./make. Sh install commands to compile and install

If the unzip package is not installed, install it yourself

yum install -y unzip zip

Decompress tar -zxvf fastdfs_v5.05.tar. gz and go to the decompressed directory CD FastDFS. Run the./make.sh and./make. Three configuration files are generated under /etc/fdfs:

cp http.conf mime.types /etc/fdfs/

Config start tracker

CD /etc/fdfs mv tracker.conf.sample tracker.conf # change the file name, drop the sample vim treacker.conf # edit the configuration file

Modified contents:

base_path=/home/fastdfs/tracker

To create a directory: mkdir -p /home/fastdf/tracker

Above, configure the tracker will start fdfs_trackerd tracker service/etc/FDFS/tracker. Conf through the command ps – ef | grep tracker view the service is started successfully

Configuring startup Storage

Conf: CD /etc/fdfs mv storage.conf.sample storage.conf: CD /etc/fdfs mv storage.conf.sample storage.conf

Modified contents:

Base_path =/home/ fastdfs.storage store_path=/home/ fastdfs.storage Tracker_server = Server IP address :22122

To create a directory, run mkdir -p /home/fastdfs/storage

After the storage configuration is complete, start the storage service fdfs_storaged /etc/ffs/storage. conf Check the service startup status

The client configuration

CD /etc/fdfs mv client.conf.sample client.conf # Change the client extension vim client.conf # Edit client.conf

Modified contents:

Tracker_server = Server IP address :22122 HTTP. tracker_server_port=8080 # Be consistent with http.server_port in tracker.conf

Test uploading files

Prepare an image or file to the /home directory

fdfs_test /etc/fdfs/client.conf upload /home/tran.png

The output

http://10.43.0.84:8080/group1/M00/00/00/CisAVF65bZeAX5SqAAHYMCFz5F8478.png


At this time, we tried to access the picture through the browser, but it was not accessible (the firewall has been turned off).

Nginx installation

First you need to install the fastdfs-nginx-Module bridge between Nginx and FDFS

Unzip the fastdfs-nginx-module_v1.16.tar.gz file we uploaded

Tar -zxvf fastdfs-nginx-module_v1.16.tar.gz CD fastdfs-nginx-module/ SRC vim config

Edit the config file. There is a problem with the configuration path of this file


cp mod_fastdfs.conf /etc/fdfs/

vim /etc/fdfs/mod_fastdfs.conf

Modified contents:

Tracker_server = Server IP address :22122 URl_have_group_name =true # Path splice group name store_path0=/home/fastdfs/storage # This parameter must be consistent with the base_path of storage.conf

nginx

First you need to install the nginx dependent packages: pcre, zlib, openSSL

yum -y install pcre pcre-devel zlib zlib-devel openssl openssl-devel

Unzip our prepared nginx files

Tar -zxvf nginx-1.7.8.tar.gz CD nginx-1.7.8

Nginx configuration:

./configure –prefix=/usr/local/nginx –sbin-path=/usr/sbin/nginx –add-module=/opt/fdfs/fastdfs-nginx-module/src


Explanation:

–prefix specifies the installation directory –sbin-path specifies the boot command installation directory –add-module loads fastdfs-nginx-module

cd /usr/local/nginx

The configuration file is in the conf directory

Start the nginx service

Start service nginx Stop service nginx -s stop Reload the configuration file nginx -s reload


Configure the reverse proxy to Fastdfs: Modify the configuration file: our configuration file is in /usr/local/nginx/conf/

vim /usr/local/nginx/conf/nginx.conf

Add location to server listening on port 80:

location ~/group([0-9])/ {
  ngx_fastdfs_module;
}
Copy the code

Note that this location needs to come before location /

ok!!!