Using Mitutoyo cloud free server to build FastDFS basic service practice

FastDFS primary building

The free server of Sanfeng cloud is used as the learning environment

Here is a small list for Sanfeng cloud. Their free products are especially suitable for students like me

preparation

	Create a new fdfs folder under the / home folder and transfer the required file length to this folder
	System I'm the newly installed file I'll release at the end of the article


Because the pure version of Sanfeng does not have vim in it
I'll install vim here and turn off the firewall

yum -y install vim
systemctl stop firewalld.service
	The preparatory work is completed and the construction begins

Start building

Install dependencies

yum -y install libevent zlib zlib-devel pcre pcre-devel gcc gcc-c++ openssl openssl-devel libevent libevent-devel perl unzip net-tools wget
	Move to the / home/fdfs / folder to extract the 4 files you have prepared 
cd /home/fdfs	# Move to fdfs folder
tar -zxvf FastDFS_v5.05.tar.gz		# Extract the FastDFS_v5.08.tar.gz file
tar -zxvf fastdfs-nginx-module_v1.16.tar.gz		# Extract the fastdfs nginx module v1.16.tar.gz file
tar -zxvf libfastcommon-1.0.7.tar.gz		# Unzip the libfastcommon-1.0.7.tar.gz file
tar -zxvf nginx-1.18.0.tar.gz		# Unzip the nginx-1.18.0.tar.gz file

		One by one compilation processing
cd libfastcommon-1.0.7	# Move to the extracted folder
./make.sh && ./make.sh install	# Compile and install
	After installation, we need to add 32-bit support to a file of cp
cp /usr/lib64/libfastcommon.so /usr/lib		# Copy the installed so file to / usr/lib


Continue with the second

cd ../FastDFS 		#Enter the extracted folder FastDFS
./make.sh && ./make.sh install 		# Compile and install
	Copy the profile we need
cp /home/fdfs/FastDFS/conf/* /etc/fdfs/ 		# Unpack the compressed package and configure it in the / etc/fdfs / folder
	Configure tracker service
vim /etc/fdfs/tracker.conf		# Configure tracker service
	Here I changed the default path. It's useful to remember
base_path=/fastdfs/tracker			# Change default path
store_group=yidu		# Change default group
	New path just configured
cd /		# Move to root
mkdir /fastdfs/tracker -p		# New tracker path
cd /fastdfs			
mkdir storage		# Create a new used folder storage client tmp under fasrdfs
mkdir client
mkdir tmp
	Start the configured tracker.conf
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf
	Start to configure storage
vim /etc/fdfs/storage.conf
	Here, the default organization name, the default save path and the ip address of the tracker? Server are changed
group_name=yidu
base_path=/fastdfs/storage
store_path0=/fastdfs/storage
tracker_server=111.67.199.33:22122
	Start the configured storage.conf
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf
	Configure client.conf
vim /etc/fdfs/client.conf
base_path=/fastdfs/client
tracker_server=111.67.199.33:22122
	Test upload. Here I upload the required file and return a URL, but I can't access it
/usr/bin/fdfs_test /etc/fdfs/client.conf upload /home/fdfs/file.zip

http://111.67.199.33/yidu/M00/00/00/b0PHIV69kZWALTCRABaDxrh95TA223_big.zip

Make the generated url accessible

	Start to configure nginx. First, finish the bridge / home / FDFS / fastdfs nginx module
cd /home/fdfs/fastdfs-nginx-module
	First, change the configuration of fastdfs nginx module
cd src
vim config
	When changing, you should carefully drop three / local


Enter the / home/fdfs/nginx-1.18.0 folder

cd /home/fdfs/nginx-1.18.0
	To copy the following code, you need to pay attention to paste the last line with your own path and press enter
./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/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi \
--add-module=/home/fdfs/fastdfs-nginx-module/src


Compile and install

make && make install


Configuration files required by cp itself

cp /home/fdfs/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs
	Modify the copied configuration file
vim /etc/fdfs/mod_fastdfs.conf


Change the default tmp path. The ip and the default organization name of the tracker? Server are consistent with the previous organization name

base_path=/fastdfs/tmp		# Change the default tmp location
taracker_server=111.67.199.33:22122		# Set ip
group_name=yidu		# Change the default group name to be consistent with the previous group name
url_have_group_name = true		# Allow access through group name
store_path0=/fastdfs/storage		# Make srotage position consistent with the front
	Configure nginx
vim /usr/local/nginx/conf/nginx.conf
	I'll use 80 port directly here
server {
	listen	80;
	server_name	111.67.199.33;
	location /yidu/M00 {
		ngx_fastdfs_module;
	}
}

	Check the configuration file and an error is reported here
/usr/local/nginx/sbin/nginx -t
	We just need to create the folder /var/temp/nginx/

mkdir /var/temp/nginx/ -p
	Check again and you can see that there has been a success


Finally, start the nginx service. In order to prevent errors, you can restart the tracker and storage

/usr/local/nginx/sbin/nginx
/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
	Here we start nginx to report an error. We just need to run the following line of code
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

It has to be explained

	Code to run the service after restart
/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
	There are many things to improve in the above configuration
	such as 
	There is a simpler way to start the service after restart, but the configuration needs to be changed
service fdfs_trackerd restart
systemctl status fdfs_trackerd.service
vim /etc/rc.d/init.d/fdfs_trackerd		#Remove all / local

service fdfs_storaged restart
systemctl status fdfs_storaged.service
vim /etc/rc.d/init.d/fdfs_storaged		#Remove all / local
	After restart, nginx will report an error and need to be changed
vim /usr/local/nginx/conf/nginx.conf
#pid        logs/nginx.pid;
pid        /usr/local/nginx/logs/nginx.pid;		# The path I changed here needs to create this file

Write a tutorial for the first time, leave a comment before leaving

	File download address

https://pan.baidu.com/s/1gN-JYc50Csq51SQ8H59jXQ

	Extraction code: r65r

Tags: Nginx vim yum zlib

Posted on Sun, 17 May 2020 01:08:21 -0700 by TheCase