table of Contents
First, prepare the environment
Tar package prepared as follows:
|
-|
fastdfs-6.06.tar.gz|
libfastcommon-1.0.43.tar.gz|
fastdfs-nginx-module-1.22.tar.gz|
nginx-1.17.7.tar.gz|
download link:
fastdfs-nginx-module,libfastcommon,fastdfs
1, using wget command to download compressed, if no command to install wget command yum
yum install wget
2, download fastdfs
wget -c "https://github.com/happyfish100/fastdfs/archive/V6.06.tar.gz" \
-O fastdfs-6.06.tar.gz
3, download libfastcommon
wget -c "https://github.com/happyfish100/libfastcommon/archive/V1.0.43.tar.gz" \
-O libfastcommon-1.0.43.tar.gz
4, download fastdfs-nginx-module
wget -c "https://github.com/happyfish100/fastdfs-nginx-module/archive/V1.22.tar.gz" \
-O fastdfs-nginx-module-1.22.tar.gz
5, download nginx
wget -c http://nginx.org/download/nginx-1.17.7.tar.gz
6, install compilation tools and libraries
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
7, turn off the firewall test environment
systemctl stop firewalld.service
8, boot disable the firewall
systemctl disable firewalld.service
9, see the firewall status
firewall-cmd --state
Second, unpack and compile and install
1, extract the downloaded package
tar -zxvf fastdfs-6.06.tar.gz
tar -zxvf fastdfs-nginx-module-1.22.tar.gz
tar -zxvf libfastcommon-1.0.43.tar.gz
tar -zxvf nginx-1.17.7.tar.gz
2, compile and install
2.1, compile and install libfastcommon
1, after the files are decompressed directory
cd /root/download/libfastcommon-1.0.43
2, compile and install
./make.sh && ./make.sh install
3, check
ls /usr/lib64|grep libfastcommon
ls /usr/lib|grep libfastcommon
Emergence of libfastcommon.so
such success
2.2, compile and install fastdfs
1, after the files are decompressed directory
cd /root/download/fastdfs-6.06
2, compile and install
./make.sh && ./make.sh install
3, check
ls /usr/bin|grep fdfs
4, enable profiles
cd /etc/fdfs/
cp storage.conf.sample storage.conf
cp client.conf.sample client.conf
cp tracker.conf.sample tracker.conf
mkdir -p /fastdfs/tracker
5, modify tracker.conf file
vi /etc/fdfs/tracker.conf
base_path = /fastdfs/tracker
6, start the tracker service
/etc/init.d/fdfs_trackerd start
7. Check whether the service is started
ps -ef|grep fdfs`
8, modify storage.conf file
vi /etc/fdfs/storage.conf
base_path = /fastdfs/storage store_path0 = /fastdfs/storage
tracker_server = 192.168.0.154:22122
http.server_port = 80
9, create a directory
mkdir -p /fastdfs/storage
10, the start storage service
/etc/init.d/fdfs_storaged start
11, set the boot
vi /etc/rc.d/rc.local
Joining Configuration
/etc/init.d/fdfs_trackerd start
/etc/init.d/fdfs_storaged start
12, file editing client.conf
vi /etc/fdfs/client.conf
modify
base_path=/fastdfs/tracker
tracker_server=192.168.0.154:22122
2.3, and install nginx fastdfs-nginx-module
1, install pcre
yum -y install pcre pcre-devel
2, unzip into the directory
cd /root/download/nginx-1.17.7
3, add http_stub_status_module module
./configure --prefix=/usr/local/nginx --with-http_stub_status_module
4, enter /root/download/fastdfs-nginx-module-1.22/src/
cd /root/download/fastdfs-nginx-module-1.22/src/
5, edit the configuration file
vi config
6, the config file / usr / local replace / usr
:%s+/usr/local+/usr
7, enter nginx extract directory
cd /root/download/nginx-1.17.7
8, add fastdfs-nginx-module
./configure --add-module=/root/download/fastdfs-nginx-module-1.22/src/
9, compile and install
make && make install
10, copy and modify the configuration file fastdfs-ngin-module in
cp /root/download/fastdfs-nginx-module-1.22/src/mod_fastdfs.conf /etc/fdfs/
vi /etc/fdfs/mod_fastdfs.conf
Change setting
connect_timeout=10
tracker_server=192.168.0.154:22122
url_have_group_name = true
store_path0=/fastdfs/storage
11, enter fastdfd source conf directory
cd /root/download/fastdfs-6.06/conf/
11, copy http.conf, mime.types to two files under / etc / fdfs / directory
cp http.conf mime.types /etc/fdfs/
12, create a soft link, create a soft link in / fastdfs / storage file storage directory, link it to a directory to store the actual data
ln -s /fastdfs/storage/data/ /fastdfs/storage/data/M00
13, nginx configuration editor
vi /usr/local/nginx/conf/nginx.conf
Change setting
server {
listen 80;
server_name 192.168.0.154;
location ~/group([0-9])/M00 {
root /fastdfs/storage/data;
ngx_fastdfs_module;
}
}
14, start nginx
/usr/local/nginx/sbin/nginx
Third, the test
1, download the pictures to your local test
wget -c "https://gss0.baidu.com/-vo3dSag_xI4khGko9WTAnF6hhy/zhidao/wh%3D600%2C800/sign=0f6379cdd8ca7bcb7d2ecf298e39475b/42a98226cffc1e17f7efcc3f4590f603738de968.jpg" -O boy.jpg
2, test upload pictures
/usr/bin/fdfs_upload_file /etc/fdfs/client.conf /root/download/boy.jpg
Get Returns the file name
group1 / M00 / 00/00 / wKgAml4RxbyARj9lAACxR4LEYRg912.jpg
And splicing ip: http://192.168.0.154/group1/M00/00/00/wKgAml4RxbyARj9lAACxR4LEYRg912.jpg