华南农业大学Linux课程实验四——搭建⼀个FastDFS服务器

文章目录

  • 环境
  • 开始前先创建个快照
  • 步骤
    • 1、环境准备
    • 2、准备libfastcommon、fastdfs、nginx-1.15.4、fastdfs-nginx-module的包
    • 3、安装libfastcommon
    • 4、安装fastdfs(tracker+storage)
      • (1)、安装fastdfs
      • (2)、配置并启动Tracker服务
      • (3)、配置并启动Storage服务
      • (4)、可以查看下启动情况
    • 5、配置客户端
    • 6、测试FastDFS
      • (1)、建个文件,用于传输。
      • (2)、测试上传
      • (3)、测试下载
      • (4)、测试删除
    • 7、安装nginx-1.15.4及nginx的插件fastdfs-nginx-module
      • (1)、安装nginx
      • (2)、配置nginx
      • (3)、配置fastdfs-nginx-module
      • (4)、启动nginx
    • 8、测试用http访问上传到Storage的文件
  • 参考
  • 列下老师给的步骤

环境

阿里云服务器、CentOS 7.9.2009。下文要安装的nginx是1.15.4版本的。

开始前先创建个快照

创建一个云盘快照 - 云服务器 ECS - 阿里云

华南农业大学Linux课程实验四——搭建⼀个FastDFS服务器_第1张图片

步骤

1、环境准备

1、安装依赖的环境

# 一次性下载多个依赖包
# FastDFS是C语言开发,安装FastDFS需要先从官网下载源码,然后进行编译,但编译依赖gcc环境,所以里面有gcc gcc-c++。
# 其他依赖包也一样,FastDFS依赖它们,所以要下载它们。
[root@wu1 init.d]# yum install wget git gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel -y

2、打开安全组的22122和23000和80端口,在阿里云网站上。
华南农业大学Linux课程实验四——搭建⼀个FastDFS服务器_第2张图片
在这里插入图片描述

3、打开防火墙的22122和23000和80端口。
可以用命令打开。

# FastDFS-Tracker
firewall-cmd --zone=public --add-port=22122/tcp --permanent
# FastDFS-Storage
firewall-cmd --zone=public --add-port=23000/tcp --permanent
# Nginx默认监听80端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
# 重新加载后才能生效
firewall-cmd --reload

我直接用宝塔面板打开的。
华南农业大学Linux课程实验四——搭建⼀个FastDFS服务器_第3张图片
在这里插入图片描述

4、提前建立tracker和storage的存储数据和日志文件的目录

[root@wu1 ~]# mkdir -p /home/fastdfs/tracker	#  后面把它设为:tracker的存储数据和日志文件的目录
[root@wu1 ~]# mkdir -p /home/fastdfs/storage	#  后面把它设为:storage的存储数据和日志文件的目录

2、准备libfastcommon、fastdfs、nginx-1.15.4、fastdfs-nginx-module的包

可以命令下载:

[root@wu1 ~]# cd /usr/local/src
[root@wu1 src]# git clone https://github.com/happyfish100/libfastcommon.git --depth 1		# libfastcommon。它是FastDFS官方提供的,包含了FastDFS运行所需要的一些基础库。
[root@wu1 src]# git clone https://github.com/happyfish100/fastdfs.git --depth 1	# fastdfs
[root@wu1 src]# git clone https://github.com/happyfish100/fastdfs-nginx-module.git --depth 1		# nginx+fastdfs的插件
[root@wu1 src]# wget http://nginx.org/download/nginx-1.15.4.tar.gz		# nginx
[root@wu1 src]# tar -zxvf nginx-1.15.4.tar.gz
[root@wu1 src]# rm -rf /usr/local/src/nginx-1.15.4.tar.gz

也可以直接把老师给的附件的几个包传输过去。我是直接传输的。
最后,/usr/local/src目录下,有这四个文件。
在这里插入图片描述

3、安装libfastcommon

[root@wu1 src]# cd /usr/local/src/libfastcommon/
[root@wu1 libfastcommon]# chmod 744 /usr/local/src/libfastcommon/make.sh 	# 让用户有执行/usr/local/src/libfastcommon/make.sh文件的权限
[root@wu1 libfastcommon]# ./make.sh
[root@wu1 libfastcommon]# ./make.sh install		#下方复制了下这个命令的输出,这些输出显示出该命令做了哪些操作
mkdir -p /usr/lib64
mkdir -p /usr/lib
mkdir -p /usr/include/fastcommon
install -m 755 libfastcommon.so /usr/lib64
install -m 644 common_define.h hash.h chain.h logger.h base64.h shared_func.h pthread_func.h ini_file_reader.h _os_define.h sockopt.h sched_thread.h http_func.h md5.h local_ip_func.h avl_tree.h ioevent.h ioevent_loop.h fast_task_queue.h fast_timer.h process_ctrl.h fast_mblock.h connection_pool.h fast_mpool.h fast_allocator.h fast_buffer.h skiplist.h multi_skiplist.h flat_skiplist.h skiplist_common.h system_info.h fast_blocked_queue.h php7_ext_wrapper.h id_generator.h char_converter.h char_convert_loader.h common_blocked_queue.h multi_socket_client.h skiplist_set.h uniq_skiplist.h fc_list.h json_parser.h buffered_file_writer.h server_id_func.h /usr/include/fastcommon
if [ ! -e /usr/lib/libfastcommon.so ]; then ln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.so; fi

4、安装fastdfs(tracker+storage)

(1)、安装fastdfs

[root@wu1 libfastcommon]# cd /usr/local/src/fastdfs
[root@wu1 fastdfs]# chmod 744 /usr/local/src/fastdfs/make.sh 
[root@wu1 fastdfs]# ./make.sh
[root@wu1 fastdfs]# ./make.sh install		# 下方复制了下这个命令的输出,这些输出显示出该命令做了哪些操作
mkdir -p /usr/bin
mkdir -p /etc/fdfs
cp -f fdfs_trackerd /usr/bin
if [ ! -f /etc/fdfs/tracker.conf.sample ]; then cp -f ../conf/tracker.conf /etc/fdfs/tracker.conf.sample; fi
if [ ! -f /etc/fdfs/storage_ids.conf.sample ]; then cp -f ../conf/storage_ids.conf /etc/fdfs/storage_ids.conf.sample; fi
mkdir -p /usr/bin
mkdir -p /etc/fdfs
cp -f fdfs_storaged  /usr/bin
if [ ! -f /etc/fdfs/storage.conf.sample ]; then cp -f ../conf/storage.conf /etc/fdfs/storage.conf.sample; fi
mkdir -p /usr/bin
mkdir -p /etc/fdfs
mkdir -p /usr/lib64
mkdir -p /usr/lib
cp -f fdfs_monitor fdfs_test fdfs_test1 fdfs_crc32 fdfs_upload_file fdfs_download_file fdfs_delete_file fdfs_file_info fdfs_appender_test fdfs_appender_test1 fdfs_append_file fdfs_upload_appender fdfs_regenerate_filename /usr/bin
if [ 0 -eq 1 ]; then cp -f libfdfsclient.a /usr/lib64; cp -f libfdfsclient.a /usr/lib/;fi
if [ 1 -eq 1 ]; then cp -f libfdfsclient.so /usr/lib64; cp -f libfdfsclient.so /usr/lib/;fi
mkdir -p /usr/include/fastdfs
cp -f ../common/fdfs_define.h ../common/fdfs_global.h ../common/mime_file_parser.h ../common/fdfs_http_shared.h ../tracker/tracker_types.h ../tracker/tracker_proto.h ../tracker/fdfs_shared_func.h ../tracker/fdfs_server_id_func.h ../storage/trunk_mgr/trunk_shared.h tracker_client.h storage_client.h storage_client1.h client_func.h client_global.h fdfs_client.h /usr/include/fastdfs
if [ ! -f /etc/fdfs/client.conf.sample ]; then cp -f ../conf/client.conf /etc/fdfs/client.conf.sample; fi

linux中/etc是配置文件的目录,这里把fastdfs的配置文件复制过去,后面修改的是/etc/fdfs下的配置文件。

[root@wu1 fastdfs]# cp /usr/local/src/fastdfs/conf/* /etc/fdfs

(2)、配置并启动Tracker服务

[root@wu1 fastdfs]# vim /etc/fdfs/tracker.conf	# 下方是修改后的base_path的配置

# 存储数据和日志文件的基本路径
base_path = /home/fastdfs/tracker

# 启动tracker
[root@wu1 fastdfs]# /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf

(3)、配置并启动Storage服务

[root@wu1 fastdfs]# vim /etc/fdfs/storage.conf	# 下方是修改后的几个配置

# 存储数据和日志文件的基本路径
base_path = /home/fastdfs/storage
# 存储路径,基于0,配置存储路径以存储文件
store_path0 = /home/fastdfs/storage
# tracker_server的地址,因为我们把tracker和storage安装在同一台服务器上,所以这里的ip填当前服务器的公网ip
tracker_server = 填写你的tracker服务器的ip地址:22122

# 启动storage
[root@wu1 fastdfs]# /usr/bin/fdfs_storaged /etc/fdfs/storage.conf 

(4)、可以查看下启动情况

[root@wu1 fastdfs]# ps -ef | grep fdfs
root     24550     1  0 16:34 ?        00:00:00 /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf	# tracker已经启动
root     25609     1  0 16:51 ?        00:00:00 /usr/bin/fdfs_storaged /etc/fdfs/storage.conf	# storage已经启动
root     28436 20871  0 17:33 pts/0    00:00:00 grep --color=auto fdfs	# 当前的grep命令
或者
[root@wu1 src]# netstat -ntlp | grep fdfs
tcp        0      0 0.0.0.0:23000           0.0.0.0:*               LISTEN      25609/fdfs_storaged 
tcp        0      0 0.0.0.0:22122           0.0.0.0:*               LISTEN      24550/fdfs_trackerd 

5、配置客户端

[root@wu1 fastdfs]# cp /usr/local/src/fastdfs/client/libfdfsclient.so /usr/lib
cp: overwrite ‘/usr/lib/libfdfsclient.so’? y

[root@wu1 fastdfs]# vim /etc/fdfs/client.conf		# 下方是修改后的几个配置

base_path = /home/fastdfs/tracker
tracker_server = 填写你的tracker服务器的ip地址:22122

6、测试FastDFS

(1)、建个文件,用于传输。

[root@wu1 fastdfs]# vim /root/hi.html		# 下方是文件内容

hi,fastdfs!

(2)、测试上传

# 复制了下输出,输出中展示了它把文件传到了哪里。
[root@wu1 fastdfs]# /usr/bin/fdfs_test /etc/fdfs/client.conf upload /root/hi.html		
This is FastDFS client test program v6.06

Copyright (C) 2008, Happy Fish / YuQing

FastDFS may be copied only under the terms of the GNU General
Public License V3, which may be found in the FastDFS source kit.
Please visit the FastDFS Home Page http://www.fastken.com/ 
for more detail.

[2021-04-16 17:48:32] DEBUG - base_path=/home/fastdfs/tracker, connect_timeout=5, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s, use_storage_id=0, storage server id count: 0

tracker_query_storage_store_list_without_group: 
	server 1. group_name=, ip_addr=120.77.151.233, port=23000

group_name=group1, ip_addr=120.77.151.233, port=23000
storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/eE2X6WB5XXCAV7AqAAAADB16GbY23.html
source ip address: 120.77.151.233
file timestamp=2021-04-16 17:48:32
file size=12
file crc32=494541238
example file url: http://120.77.151.233/group1/M00/00/00/eE2X6WB5XXCAV7AqAAAADB16GbY23.html
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/eE2X6WB5XXCAV7AqAAAADB16GbY23_big.html
source ip address: 120.77.151.233
file timestamp=2021-04-16 17:48:32
file size=12
file crc32=494541238
example file url: http://120.77.151.233/group1/M00/00/00/eE2X6WB5XXCAV7AqAAAADB16GbY23_big.html

# 上方回应的路径,告诉你它把文件放到哪里去了,你可以去那个目录下找。
[root@wu1 fastdfs]# cd /home/fastdfs/storage/data/00/00/

# 可以看到文件被传上去了。但此时,只有我们服务器内部可以访问,外部访问不了。
# 因为FastDFS无法处理http请求,于是,我们需要安装能处理http请求的Nginx,Nginx还有负载均衡的能力。
[root@wu1 00]# ll
total 16
-rw-r--r-- 1 root root 12 Apr 16 17:48 eE2X6WB5XXCAV7AqAAAADB16GbY23_big.html
-rw-r--r-- 1 root root 49 Apr 16 17:48 eE2X6WB5XXCAV7AqAAAADB16GbY23_big.html-m
-rw-r--r-- 1 root root 12 Apr 16 17:48 eE2X6WB5XXCAV7AqAAAADB16GbY23.html
-rw-r--r-- 1 root root 49 Apr 16 17:48 eE2X6WB5XXCAV7AqAAAADB16GbY23.html-m

(3)、测试下载

[root@wu1 fastdfs]# cd /usr/local/src

# 复制了下输出,可以看到下载成功,通过命令ll可以看到下载到了当前目录下。
[root@wu1 src]# /usr/bin/fdfs_test /etc/fdfs/client.conf download group1 M00/00/00/eE2X6WB5XXCAV7AqAAAADB16GbY23.html	
This is FastDFS client test program v6.06

Copyright (C) 2008, Happy Fish / YuQing

FastDFS may be copied only under the terms of the GNU General
Public License V3, which may be found in the FastDFS source kit.
Please visit the FastDFS Home Page http://www.fastken.com/ 
for more detail.

[2021-04-17 17:53:06] DEBUG - base_path=/home/fastdfs/tracker, connect_timeout=5, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s, use_storage_id=0, storage server id count: 0

storage=120.77.151.233:23000
download file success, file size=12, file save to eE2X6WB5XXCAV7AqAAAADB16GbY23.html

(4)、测试删除

(别真删除,这里只是先列下删除要用的命令。可以后面安装完nginx和nginx的插件,测试完可以用http访问上传到Storage的文件,再回来测试删除。)

[root@wu1 src]# /usr/bin/fdfs_test /etc/fdfs/client.conf delete group1 M00/00/00/eE2X6WB5XXCAV7AqAAAADB16GbY23.html	

7、安装nginx-1.15.4及nginx的插件fastdfs-nginx-module

为什么要安装nginx?
1、让FastDFS具备http访问的能力。
2、使FastDFS有负载均衡的能力。

华南农业大学Linux课程实验四——搭建⼀个FastDFS服务器_第4张图片

(1)、安装nginx

[root@wu1 src]# cd /usr/local/src/nginx-1.15.4

# /usr/local/src/nginx-1.15.4/configure是可执行文件。
# --add-module指定扩展模块的路径。
# 默认把nginx安装到/usr/local目录下,即安装完成后多出一个/usr/local/nginx的文件夹。
[root@wu1 nginx-1.15.4]# ./configure --add-module=/usr/local/src/fastdfs-nginx-module/src/	# 列一下部分输出
。。。。。。
configuring additional modules
adding module in /usr/local/src/fastdfs-nginx-module/src/
 + ngx_http_fastdfs_module was configured
checking for PCRE library ... found
checking for PCRE JIT support ... found
checking for zlib library ... found
creating objs/Makefile

Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + using system zlib library

  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

[root@wu1 nginx-1.15.4]# make
[root@wu1 nginx-1.15.4]# make install

(2)、配置nginx

[root@wu1 nginx-1.15.4]# cd /usr/local/nginx/conf
[root@wu1 conf]# cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak	  # .bak是备份文件,备份下nginx.conf文件
[root@wu1 conf]# vim /usr/local/nginx/conf/nginx.conf		# 在该文件中插入下方内容,插入位置如下图所示

# 拦截请求路径中包含/group[1-9]/M0[0-9]的请求,用fastdfs的Nginx模块进行转发
location ~ /group[1-9]/M0[0-9]{
	ngx_fastdfs_module;
}

华南农业大学Linux课程实验四——搭建⼀个FastDFS服务器_第5张图片

(3)、配置fastdfs-nginx-module

[root@wu1 conf]# cp /usr/local/src/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
[root@wu1 conf]# vim /etc/fdfs/mod_fastdfs.conf 	# 修改下方配置

# 存储日志文件的基本路径。这里可改可不改
base_path=/tmp

# tracker_server的ip地址
tracker_server=你安装tracker的服务器的ip:22122

# 请求中是不是包含组名
# 当uri类似于/M00/00/00/xxx时设置为false
# 当uri类似于${group_name}/M00/00/00/xxx时,如group1/M00/xxx,则设置为true
url_have_group_name = true

# 文件存放路径
# store_path#, based 0, 如果 store_path0 不存在, 其值是 base_path
# 必须和storage.conf(/etc/fdfs/storage.conf)里配置的store_path0相同
store_path0=/home/fastdfs/storage

(4)、启动nginx

[root@wu1 conf]# /usr/local/nginx/sbin/nginx		# /usr/local/nginx/sbin/nginx该文件是可执行文件
ngx_http_fastdfs_set pid=28285		#返回pid表示启动成功
[root@wu1 conf]# ps -ef | grep nginx		# 要nginx的master和worker都启动,如下,才是启动了nginx
root     28286     1  0 19:04 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody   28287 28286  0 19:04 ?        00:00:00 nginx: worker process
root     28334  9106  0 19:05 pts/1    00:00:00 grep --color=auto nginx

8、测试用http访问上传到Storage的文件

华南农业大学Linux课程实验四——搭建⼀个FastDFS服务器_第6张图片

参考

CentOS7使用firewall-cmd打开关闭防火墙与端口_s_p_j的专栏-CSDN博客_firewall-cmd

手把手带你安装FastDFS及与SpringBoot整合_哔哩哔哩 (゜-゜)つロ 干杯~-bilibili

列下老师给的步骤

1. 关闭虚拟机
2. 设置 > CD/DVD 取消 Connect CD/DVD Drive。选择AutoDetect
3. 菜单 > 文件 > 导出 > OVA格式 等待导出结束
4. 菜单 > 文件 > 导入 > 选择文件路径 > 修改配置(cpu, 内存,硬盘)
5. 启动新导入的虚拟机 查看IP。ip addr
    修改IP(静态IP)vi \ifcfg-ens32
    service network restart
    ping www.baidu.com
6. 启动原来的虚拟机,测试虚拟机之间的连通性(ping)。SecureCRT远程连上。
7. 挂起新机器。快照走起
8. 演示 三台 10.10.10.102/103/104
    102 storage tracker nginx
    103 tracker client
    104 storage  nginx

9. 初始化 view -> command window 右键 send command to all sessions

#shutdown selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
cat /etc/selinux/config

#install iptables # firewalld
service iptables status
service firewalld status
service firewalld stop
systemctl disable firewalld

yum install -y iptables-services #安装
systemctl enable iptables #开机自启动
systemctl start iptables #启动
systemctl status iptables #查看状态


#reboot
reboot

10. 安装  storage和tracker的区别在于配置文件上
#下载依赖包
yum install wget git gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel -y

#下载fastDFS
cd /usr/local/src
git clone https://github.com/happyfish100/libfastcommon.git --depth 1
git clone https://github.com/happyfish100/fastdfs.git --depth 1

如果git下载很慢,打包上传到linux,然后解压到指定目录
rz
tar zxvf fastdfs.tar.gz
mv fastdfs fastdfs-nginx-module libfastcommon /usr/local/src/

#安装libfatscommon
cd /usr/local/src/libfastcommon
./make.sh && ./make.sh install
保证不出ERROR错误

#安装FastDFS
cd /usr/local/src/fastdfs
./make.sh && ./make.sh install
保证不出ERROR错误

11 配置 tracker
mkdir -p /home/fastdfs/tracker
cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf
sed -i 's?base_path = /home/yuqing/fastdfs?base_path = /home/fastdfs/tracker?g' /etc/fdfs/tracker.conf
/etc/init.d/fdfs_trackerd start | stop
chkconfig fdfs_trackerd on #开机自启动

netstat -ntlp | grep fdfs

cat /etc/sysconfig/iptables
sed -i "10 a -A INPUT -p tcp -m state --state NEW -m tcp --dport 22122 -j ACCEPT" /etc/sysconfig/iptables
cat /etc/sysconfig/iptables
service iptables restart
ls /home/fastdfs/tracker

12 配置 storage
mkdir -p /home/fastdfs/storage
cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf
sed -i 's?base_path = /home/yuqing/fastdfs?base_path = /home/fastdfs/storage?g' /etc/fdfs/storage.conf
sed -i 's?store_path0 = /home/yuqing/fastdfs?store_path0 = /home/fastdfs/storage?g' /etc/fdfs/storage.conf

vi /etc/fdfs/storage.conf
#tracker_server
tracker_server = 10.10.10.102:22122
tracker_server = 10.10.10.103:22122


/etc/init.d/fdfs_storaged start
chkconfig fdfs_storaged on
chkconfig fdfs_storaged --list

netstat -ntlp | grep fdfs


sed -i "10 a -A INPUT -p tcp -m state --state NEW -m tcp --dport 23000 -j ACCEPT" /etc/sysconfig/iptables
service iptables restart
cat /etc/sysconfig/iptables

/usr/bin/fdfs_monitor /etc/fdfs/storage.conf

13 测试上传 #在tracker上测试
cp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf
sed -i 's?base_path = /home/yuqing/fastdfs?base_path = /home/fastdfs/tracker?g' /etc/fdfs/client.conf
vi /etc/fdfs/client.conf
tracker_server = 10.10.10.102:22122
tracker_server = 10.10.10.103:22122

/usr/bin/fdfs_upload_file /etc/fdfs/client.conf /usr/local/src/fastdfs/COPYING-3_0.txt
cd /home/fastdfs/storage/data/00/00/***

/usr/bin/fdfs_download_file /etc/fdfs/client.conf group1/M00/00/00/CgoKZl6evi6AIFQ0AACI-7zX1qU910.txt


14 配置nginx #需要部署在storage机器上
cp /usr/local/src/fastdfs/conf/http.conf /etc/fdfs/
cp /usr/local/src/fastdfs/conf/mime.types /etc/fdfs/

cd /usr/local/src
git clone https://github.com/happyfish100/fastdfs-nginx-module.git --depth 1
wget http://nginx.org/download/nginx-1.15.4.tar.gz
tar -zxvf nginx-1.15.4.tar.gz
cd nginx-1.15.4/
./configure --add-module=/usr/local/src/fastdfs-nginx-module/src/ 
make && make install

mv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak	

cp /root/fastdfs/nginx.conf /usr/local/nginx/conf/nginx.conf

cp /usr/local/src/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
sed -i 's?store_path0=/home/yuqing/fastdfs?store_path0=/home/fastdfs/storage?g' /etc/fdfs/mod_fastdfs.conf
sed -i 's/url_have_group_name = false/url_have_group_name = true/g' /etc/fdfs/mod_fastdfs.conf

vi /etc/fdfs/mod_fastdfs.conf
tracker_server = 10.10.10.102:22122
tracker_server = 10.10.10.103:22122

cp /root/fastdfs/nginx.service /lib/systemd/system/
systemctl enable nginx.service
service nginx start
ps -ef | grep nginx

sed -i "10 a -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT" /etc/sysconfig/iptables
sed -i "10 a -A INPUT -p tcp -m state --state NEW -m tcp --dport 8888 -j ACCEPT" /etc/sysconfig/iptables
service iptables restart

http://ip:port/group*/M**/...

一些命令还没学,所以比较难懂,可以看下方的网址理解下:
sed linux命令 在线中文手册

如何让一个服务或脚本开机自启动?-李导的博客-51CTO博客
chkconfig的原理 和添加开机自启动的办法 - 陈雷雷 - 博客园

还比如:

sed -i "10 a -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT" /etc/sysconfig/iptables		# 通过修改/etc/sysconfig/iptables文件来开启防火墙80端口

你可能感兴趣的:(linux,fastdfs,nginx,centos)