##################
##   服务端配置   ##
##################
mkdir /ycx/upload
mkdir -p /ycx/data/nginx/html

# 安装nfs
yum -y install nfs-utils

# 共享文件夹
vi /etc/exports

/ycx/upload 10.176.22.98(rw,root_squash)
/ycx/upload 10.176.22.99(rw,root_squash)

/ycx/data/nginx/html 10.176.22.98(rw,root_squash)
/ycx/data/nginx/html 10.176.22.99(rw,root_squash)

# 共享生效
exportfs -a

# 设置权限,很重要
chown -R nfsnobody.nfsnobody /ycx/upload
chown -R nfsnobody.nfsnobody /deya/data/nginx/html
# 检查共享目录是否设置正确 showmount
-e # 开机启用 systemctl enable nfs # 启动nfs systemctl start nfs # 停用防火墙 systemctl stop firewalld.service ################## ## 客户端配置 ## ################## mkdir /ycx/upload mkdir -p /ycx/data/nginx/html # 安装nfs yum -y install nfs-utils rpcbind # 开机启用 systemctl enable nfs # 启动nfs systemctl start nfs # 检查共享目录是否设置正确 showmount -e 10.176.22.132 # 挂载服务端硬盘到客户端服务器 mount -t nfs 10.176.22.132:/ycx/upload /deya/upload mount -t nfs 10.176.22.132:/ycx/data/nginx/html /ycx/data/nginx/html # 取消挂载 umount 10.176.22.132:/ycx/upload umount 10.176.22.132:/ycx/data/nginx/html